```go
package main
import (
"fmt"
)
func totalLines(v, k int) int {
total := 0
current := v
for current > 0 {
total += current
current = current / k
}
return total
}
func main() {
var n, k int
fmt.Scan(&n, &k)
lo, hi := 0, n
// Find upper bound
for totalLines(hi, k) < n {
hi *= 2
}
for lo < hi {
mid := (lo + hi) / 2
if totalLines(mid, k) >= n {
hi = mid
} else {
lo = mid + 1
}
}
fmt.Println(lo)
}
```