Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles.

Vasily has a candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smart, so he can make b went out candles into a new candle. As a result, this new candle can be used like any other new candle.

Now Vasily wonders: for how many hours can his candles light up the room if he acts optimally well? Help him find this number.


-----Input-----

The single line contains two integers, a and b (1 ≤ a ≤ 1000; 2 ≤ b ≤ 1000).


-----Output-----

Print a single integer — the number of hours Vasily can light up the room for.


-----Examples-----
Input
4 2

Output
7

Input
6 3

Output
8



-----Note-----

Consider the first sample. For the first four hours Vasily lights up new candles, then he uses four burned out candles to make two new ones and lights them up. When these candles go out (stop burning), Vasily can make another candle. Overall, Vasily can light up the room for 7 hours.

Difficulty: interview

Starter code:

Solutions:
a, b = map(int, input().split())
k = a
x = 0
count = 0
while k > 0:
    k -= 1
    x += 1
    if x == b:
        x = 0
        k += 1
    count += 1
print(count)

a, b = list(map(int, input().split()))
c = 0
ans = 0
while a > 0:
    ans += a
    c += a
    a = c // b
    c %= b
print(ans)


a,b=list(map(int,input().split()))

ans=a
while(a>=b):

    ans+=a//b
    a=a//b+a%b


print(ans)


a,b = list(map(int,input().split()))
out = a
while a >= b:
    out += (a // b)
    a = (a // b) + (a % b)
print(out)


a, b = list(map(int, input().split()))
ans = a
while a >= b:
    f = a // b
    ans += f
    a = a % b + f
print(ans)


a, b = map(int, input().split())
ans = 0
while a >= b:
    ans += a - a % b
    a = a // b + a % b
print(ans + a)

a, b = list(map(int, input().split()))
r = 0
while a > 0:
    if a >= b:
        r += b
        a = a - b + 1
    else:
        r += a
        a = 0
print(r)


def __starting_point():
    a, b = map(int, input().split())
    ans = a
    while a // b > 0:
        ans += a // b
        a = a // b + a % b
    print(ans)
__starting_point()

a,b = list(map(int, input().split()))
c = a
d = 0
s = 0
while c:
    s += c
    d += c
    c = d // b
    d %= b
print(s)



a,b = list(map(int,input().split()))
poc = 0
while a >= b:
	x = a//b
	zv = a%b
	x = x*b
	poc+=x
	a = x//b+zv
print(poc+a)


#-*- coding: utf-8 -*-

a, b = list(map(int, input().split()))

n = 0
shorele = 0

while a > 0:
    n += a
    shorele += a
    a = shorele // b
    shorele = shorele % b


print(n)


import sys

sys.setrecursionlimit(280000)
a, b = map(int, input().split())
ans = 0
dead = a
while a>=b:
    ans += a - a % b
    dx = a-a%b
    a-= dx
    a+= dx//b
print(ans+a)

a, b = map(int, input().split())
s=a
while a//b:
    s+=a//b
    a=a//b+a%b
print(s)

from sys import stdin, stdout

def solve(a, b):
	result = 0
	old = 0
	while a != 0:
		result += a
		neww = (a + old) // b
		old = (a + old) % b
		a = neww
	return result

def __starting_point():
	s = stdin.readline()
	(a, b) = s.split(' ')
	a = int(a)
	b = int(b)
	result = solve(a, b)
	print(result)
	# a = int(a)
	# b = int(b)
	# result = solve(a, b)
	# print(result)

__starting_point()

k = input().split(" ")
a = int(k[0])
b = int(k[1])
res = 0
p=0
while a!=0:
    res += a
    p += a
    a = p//b
    p = p-a*b
print(res)


k = input().split(" ")
a = int(k[0])
b = int(k[1])
res = 0
p=0
while a!=0:
    res += a
    p += a
    a = p//b
    p = p-a*b
print(res)

a,b=map(int,input().split())
ans=0
a1=a
r=0
while a1!=0:
    ans+=a1
    a1=(a+r)//b
    r=a+r-a1*b
    a=a1
print(ans)

a,b = map(int,input().split())
s = a
while  a // b:
    s += a // b
    a = a % b + a // b
print(s)

a, b = map(int, input().split())
c = k = 0
while a:
    k += a
    a, c = (a + c) // b, (a + c) % b
print(k)

a, b = list(map(int, input().split()))
ans=0

while(a>=b):
    ans=ans+b
    a=a-b+1
print(ans+a)


a,b=list(map(int,input().split()))
result=a
while a>=b:
    result+=a//b
    a=a//b+a%b
print(result)


a,b=map(int,input().split())
x = a // b
i = 0
s = a
while x >= 1 :
    i = i + x
    s = x + s - x * b
    x = s // b
print(a + i)

a,b=input().split( )
a=int(a)
b=int(b)
t=a
while a//b>=1:
    t+=a//b
    a=a//b+a%b
print(t)



s=input().split(' ')
a=int(s[0])
b=int(s[1])
r=0
s=0
while (a>0):
    s=s+a
    new=(a+r)//b
    r=(a+r)%b
    a=new
    
print(s)