from fractions import Fraction
from sys import stdin
a, b = map(int, stdin.read().split())
f = Fraction(a,b)
time = a
while f >= 1:
    t = int(f)
#    print t
    time += t
    f = f - t + Fraction(t,  b)
print time
