Little Lesha loves listening to music via his smartphone. But the smartphone doesn't have much memory, so Lesha listens to his favorite songs in a well-known social network InTalk.

Unfortunately, internet is not that fast in the city of Ekaterinozavodsk and the song takes a lot of time to download. But Lesha is quite impatient. The song's duration is T seconds. Lesha downloads the first S seconds of the song and plays it. When the playback reaches the point that has not yet been downloaded, Lesha immediately plays the song from the start (the loaded part of the song stays in his phone, and the download is continued from the same place), and it happens until the song is downloaded completely and Lesha listens to it to the end. For q seconds of real time the Internet allows you to download q - 1 seconds of the track.

Tell Lesha, for how many times he will start the song, including the very first start.


-----Input-----

The single line contains three integers T, S, q (2 ≤ q ≤ 10^4, 1 ≤ S < T ≤ 10^5).


-----Output-----

Print a single integer — the number of times the song will be restarted.


-----Examples-----
Input
5 2 2

Output
2

Input
5 4 7

Output
1

Input
6 2 3

Output
1



-----Note-----

In the first test, the song is played twice faster than it is downloaded, which means that during four first seconds Lesha reaches the moment that has not been downloaded, and starts the song again. After another two seconds, the song is downloaded completely, and thus, Lesha starts the song twice.

In the second test, the song is almost downloaded, and Lesha will start it only once.

In the third sample test the download finishes and Lesha finishes listening at the same moment. Note that song isn't restarted in this case.

Difficulty: MEDIUM
Tags: Mathematics

Implementation

Starter code:

Solutions:
(T, S, q) = map(int, input().split())
count = 0
while True:
	count += 1
	ds = S * (q - 1)
	S += ds
	if S >= T:
		break
print(count)


(T, S, q) = tuple((int(i) for i in input().split()))
currcount = 0
while S < T:
	S *= q
	currcount += 1
print(currcount)


(T, S, q) = map(int, input().split())
ans = 1
p = 0
while True:
	S = S + (q - 1)
	p += q
	if S >= T:
		break
	if p >= S:
		p = 0
		ans += 1
print(ans)


(t, s, q) = map(int, input().split(' '))
ans = 0
while s < t:
	s *= q
	ans += 1
print(ans)


import math, os, sys
import string, re
from itertools import *
from collections import Counter
from operator import mul

def inputint():
	return int(input())

def inputarray(func=int):
	return map(func, input().split())

def inputarray2(n, func=int):
	for _ in range(n):
		yield func(input())
(T, S, q) = inputarray()
(i, g) = (0, S)
while g < T:
	i = i + 1
	g = g + (q - 1) * g
print(i)


import sys
import random
import os
(t, s, q) = input().split()
t = int(t)
s = int(s)
q = int(q)
ans = 0
while s < t:
	s = s * q
	ans += 1
print(ans)


(T, t, q) = map(int, input().split())
n = 1
while t < T:
	t += t * (q - 1)
	if t < T:
		n += 1
print(n)


nums = input().split()
T = int(nums[0])
S = int(nums[1])
q = int(nums[2])
answer = 1
while S * q < T:
	S = S * q
	answer += 1
print(answer)


import math
(t, s, q) = map(int, input().split())
a = 0
c = 0
tim = a
while t > s:
	s = s * q
	a += 1
print(a)


(t, s, q) = [int(i) for i in input().split()]
c = (q - 1) / q
cnt = 1
time = s
while True:
	time = time / (1 - c)
	if t - time <= 0.0001:
		break
	cnt += 1
print(cnt)


def main():
	(t, s, q) = map(int, input().split())
	res = 0
	while s < t:
		s *= q
		res += 1
	print(res)
main()


(t, s, q) = map(int, input().split())
p = 0
while s < t:
	s = s * q
	p += 1
print(p)


(t, s, q) = input().split()
t = int(t)
s = int(s)
q = int(q)
r = s
m = 1
while r < t:
	r = r * q
	if r < t:
		m += 1
print(m)


(t, s, q) = map(int, input().split())
c = s
ans = 1
while s < t:
	s += q - 1
	c -= 1
	if c == 0 and s < t:
		ans += 1
		c = s
print(ans)


(n, m, r) = list(map(int, input().split()))
o = 0
while m < n:
	m *= r
	o += 1
print(o)


(t, s, q) = map(int, input().split())
c = 0
while s < t:
	s *= q
	c += 1
print(c)


def Music2(T, S, q):
	intersect = S * q
	count = 1
	while intersect < T:
		count += 1
		intersect = S * q ** count
	return count
s = input()
s = s.split()
print(Music2(int(s[0]), int(s[1]), int(s[2])))


(t, s, q) = [int(x) for x in input().split()]
count = 1
s *= q
while t > s:
	s *= q
	count += 1
print(count)


(T, S, q) = (int(token) for token in input().split())
out = 0
while S <= T:
	S = q * S
	out += 1
	if S == T:
		break
print(out)


(t, s, q) = map(int, input().split())
cnt = 0
while s < t:
	s = s * q
	cnt += 1
print(cnt)


in_params = list(map(int, input().split()))
song_duration = in_params[0]
downloaded = in_params[1]
q = in_params[2]
d = float(q - 1) / q
replays = 1
x = downloaded * d / (1 - d)
while downloaded + x < song_duration - 1e-06:
	replays += 1
	downloaded += x
	x = downloaded * d / (1 - d)
print(replays)


(T, S, q) = map(int, input().split())
count = 0
while S < T:
	S *= q
	count += 1
print(count)


(T, S, q) = [int(i) for i in input().split(' ')]
res = 1
loaded = S
while loaded * q < T:
	loaded = loaded * q
	res += 1
print(res)


(T, S, q) = list(map(int, input().split()))
a = 0
while T > S:
	S *= q
	a += 1
print(a)


line = input()
(T, S, q) = [int(i) for i in line.split(' ')]
(count, total) = (0, 1)
while S < T:
	S *= q
	count += 1
print(count)


from math import log
(T, S, q) = map(int, input().split())
print(int(log(T / S - 0.1) / log(q)) + 1)


(t, s, q) = list(map(int, input().split()))
r = 1
while t > s * q:
	s *= q
	r += 1
print(r)


(t, s, q) = map(int, input().split())
i = 0
t -= s
while t > 0:
	t -= s * q ** i * (q - 1)
	i += 1
print(i)


(T, S, q) = map(int, input().split())
ans = 0
while S < T:
	S *= q
	ans += 1
print(ans)


(dur, downloaded, sec) = map(int, input().split())
times = 0
while downloaded < dur:
	downloaded *= sec
	times += 1
print(times)


tsq = input().split(' ')
t = int(tsq[0])
s = int(tsq[1])
q = int(tsq[2])
ans = 0
while s < t:
	ans += 1
	s *= q
print(ans)


import time
import math
(T, S, q) = (int(i) for i in input().split())
start = time.time()
ans = math.ceil(math.log(T / S, q))
print(ans)


import math
(T, S, q) = map(int, input().split())
print(math.ceil(math.log(T / S, q)))


(t, s, q) = map(int, input().split(' '))
j = 0
while s < t:
	s *= q
	j += 1
else:
	print(j)


from math import ceil, log
(t, s, q) = [int(i) for i in input().split()]
print(ceil(log(t / s, q)))


(T, S, q) = map(int, input().split())
zap = 0
while S < T:
	S = S * q
	zap += 1
print(zap)


SS = input().split()
T = int(SS[0])
S = int(SS[1])
q = int(SS[2])
a = 0
while S < T:
	S = S + S * (q - 1)
	a += 1
print(a)


(T, S, q) = map(int, input().split())
sum = 0
while S < T:
	S *= q
	sum += 1
print(sum)


(t, s, q) = [int(i) for i in input().split()]
a = 1
l = 0
while t > s:
	l += q
	l = min(l, t)
	s += q - 1
	s = min(s, t)
	if l >= s and s != t:
		a += 1
		l = 0
print(a)


(t, s, q) = [int(x) for x in input().split()]
res = 0
while s < t:
	s = s * q
	res += 1
print(res)


(t, s, q) = map(int, input().split(' '))
k = 0
while s < t:
	s *= q
	k += 1
print(k)


(t, s, q) = map(int, input().split())
d = 0
res = 0
while True:
	res += 1
	s = q * s
	if s >= t:
		break
print(res)


(T, S, q) = map(int, input().split())
v = 1
while T > q * S:
	S += (q - 1) * S
	v += 1
print(v)


(t, s, q) = list(map(int, input().split()))
a = 0
while s < t:
	s *= q
	a += 1
print(a)


from math import ceil, log
(a, b, c) = map(int, input().split())
print(ceil(log(a / b, c)))


(a, b, c) = map(int, input().split())
ans = 1
t = 1 / c
t1 = b / t
while a > t1:
	ans += 1
	b = t1
	t1 = b / t
print(ans)


(t, s, q) = input().split()
t = int(t)
s = int(s)
q = int(q)
count = 0
while s < t:
	s *= q
	count += 1
print(count)


(T, S, q) = map(int, input().split())
r = 0
while T > S:
	S *= q
	r += 1
print(r)


def mp():
	return map(int, input().split())

def lt():
	return list(map(int, input().split()))

def pt(x):
	print(x)

def ip():
	return input()

def it():
	return int(input())

def sl(x):
	return [t for t in x]

def spl(x):
	return x.split()

def aj(liste, item):
	liste.append(item)

def bin(x):
	return '{0:b}'.format(x)

def listring(l):
	return ' '.join([str(x) for x in l])

def printlist(l):
	print(' '.join([str(x) for x in l]))
(t, s, q) = mp()
time = 0
while s < t:
	s *= q
	time += 1
print(time)


import io, os, sys
try:
	fin = open('in')
	input = fin.readline
except:
	input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(t, s, q) = map(int, input().split())
c = 0
while s < t:
	c += 1
	s *= q
print(c)


(t, s, q) = list(map(int, input().split()))
ans = 1
while True:
	x = s * q
	if x >= t:
		break
	ans += 1
	s = x
print(ans)


(T, S, q) = map(int, input().split())
s = S * q
counter = 1
while s < T:
	s *= q
	counter += 1
print(counter)


def music(lst):
	count = 0
	while lst[1] < lst[0]:
		lst[1] *= lst[2]
		count += 1
	return count
(T, s, q) = [int(i) for i in input().split()]
print(music(list((T, s, q))))


(t, s, q) = map(int, input().split())
lecture = 0
sol = 1
pas = 1 - 1 / q
piste = s
while piste < t:
	x = q * (piste - lecture)
	if piste + x * pas < t:
		sol += 1
		piste += x * pas
		lecture = 0
	else:
		break
print(sol)


from collections import *
from itertools import *
from random import *
from bisect import *
from string import *
from queue import *
from heapq import *
from math import *
from re import *
from sys import *

def fast():
	return stdin.readline().strip()

def zzz():
	return [int(i) for i in fast().split()]
(z, zz) = (input, lambda : list(map(int, z().split())))
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def output(answer):
	stdout.write(str(answer))
dx = [-1, 1, 0, 0, 1, -1, 1, -1]
dy = [0, 0, 1, -1, 1, -1, -1, 1]
(t, s, q) = zzz()

def restart(dwonloaded, q):
	return dwonloaded * q
a = 1
while restart(s, q) < t:
	s = restart(s, q)
	a += 1
print(a)


import sys
from math import *

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())
(T, S, q) = mints()
r = 0
while S < T:
	r += 1
	S += S * (q - 1)
print(r)


__author__ = 'Алексей'
(T, S, q) = map(int, input().split())
(cnt, total) = (1, q * S)
while total < T:
	cnt += 1
	total *= q
print(cnt)


(t, s, q) = map(int, input().split())
play = 0
while s < t:
	s = s * q
	play += 1
print(play)


(t, s, q) = map(int, input().split())
x = s
ans = 1
while x < t:
	ans += 1
	x += (q - 1) * s
	s = x
print(ans - 1)


import collections, itertools, functools, math, fractions

def solve():
	(T, S, q) = map(int, input().split())
	r = 0
	down = S
	while down < T:
		down *= q
		r += 1
	return r
print(solve())


(t, s, q) = map(int, input().split())
ans = 1
for i in range(t):
	s += s * (q - 1)
	if s < t:
		ans += 1
	else:
		break
print(ans)


(a, b, c) = map(int, input().split())
s = 0
while b < a:
	s += 1
	b *= c
print(s)


import time
import math
(T, S, q) = (int(i) for i in input().split())
start = time.time()
ans = math.log(T / S, q)
if int(ans) - ans != 0:
	ans = int(ans) + 1
else:
	ans = int(ans)
print(ans)
finish = time.time()


datos = input()
datos = datos.split(' ')
T = int(datos[0])
S = int(datos[1])
q = int(datos[2])
play = 0
while S < T:
	S = S * q
	play += 1
print(play)


(N, S, Q) = map(int, input().split(' '))
counter = 1
while True:
	x = round(S / (1 - (Q - 1) / Q), 9)
	if x >= N:
		break
	S = x
	counter += 1
print(counter)


from collections import *
import os, sys
from io import BytesIO, IOBase

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
BUFSIZE = 8192
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
rstr = lambda : input().strip()
rstrs = lambda : [str(x) for x in input().split()]
rstr_2d = lambda n: [rstr() for _ in range(n)]
rint = lambda : int(input())
rints = lambda : [int(x) for x in input().split()]
rint_2d = lambda n: [rint() for _ in range(n)]
rints_2d = lambda n: [rints() for _ in range(n)]
ceil1 = lambda a, b: (a + b - 1) // b
(t, s, q) = rints()
(ans, be, s, t, su) = (1, 0, s * (q - 1), t * (q - 1), 0)
while be < t:
	be += q - 1
	su += q - 1
	if be < t and be == s + su // q * (q - 1) and (su % q == 0):
		be = 0
		ans += 1
print(ans)


import math

def main():
	read = lambda : tuple(map(int, input().split()))
	(t, s, q) = read()
	print(math.ceil(math.log(t / s, q)))
main()


(t, s, q) = map(int, input().split())
r = 0
while s < t:
	s *= q
	r += 1
print(r)


(t, s, q) = list(map(int, input().split(' ')))
c = 1
while s < t:
	x = q * s - s
	s += x
	c += 1
print(c - 1)


info = list(map(int, input().split()))
t = info[0]
s = info[1]
q = info[2]
q = (q - 1) / q
p = s
ans = 0
while p < t:
	p = p / (1 - q)
	if int(p) + 1 - p < 0.005:
		p = int(p) + 1
	ans += 1
print(ans)


def music(T, S, q):
	n = 1
	while S * q ** n < T:
		n += 1
	return n
list = list(map(int, input().split()))
print(music(list[0], list[1], list[2]))


from fractions import Fraction

class CodeforcesTask569ASolution:

	def __init__(self):
		self.result = ''
		self.t_s_q = []

	def read_input(self):
		self.t_s_q = [int(x) for x in input().split(' ')]

	def process_task(self):
		starts = 1
		downloaded = Fraction(self.t_s_q[1])
		speed = Fraction(self.t_s_q[2] - 1) / Fraction(self.t_s_q[2])
		duration = Fraction(self.t_s_q[0])
		playback = Fraction()
		step = Fraction(0.5)
		while playback < duration:
			playback += step
			downloaded += speed * step
			if playback >= duration:
				break
			if playback >= downloaded:
				starts += 1
				playback = 0
		self.result = str(starts)

	def get_result(self):
		return self.result
Solution = CodeforcesTask569ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


(T, S, q) = map(int, input().split())
(t, con) = (0, S)
while S < T:
	S += con * (q - 1)
	con = S
	t += 1
print(t)


(t, s, q) = map(int, input().split(' '))
tek = 0
v = (q - 1) / q
ans = 1
if t == 6562 and s == 1 and (q == 3):
	print(9)
	exit(0)
while tek < t:
	if tek + 1 >= s + v and s + v < t:
		ans += 1
		tek = 0
		s += v
	else:
		s += v
		tek += 1
print(ans)


(t, s, q) = map(int, input().split())
init = q
count = 1
while init < t / s:
	init = init * q
	count = count + 1
print(count)


from math import log
(T, S, q) = map(int, input().split())
print(int(log(T / S - 1e-05) / log(q)) + 1 if T > S else 1)


(t, s, q) = [int(j) for j in input().split()]
k = s
ans = 0
q = q - 1
while k < t:
	k = k + k * q
	ans = ans + 1
print(ans)