import sys

[a, b] = map(int, sys.stdin.readline().strip().split())

ans = 0
residue = 0

while (a > 0):
    ans = ans + a
    temp = (a+residue)/b
    residue = a + residue - (temp*b)
    a = temp
    
print ans