import sys

x,y = [int(x) for x in raw_input().split()]
hr = 0
rem = 0
def get_remain(new, rem):
   global y, hr
   #print "B4:{} {} {}".format(hr, new, rem)
   hr += new
   rem += new
   new = rem/y
   rem = rem % y
   #print "AF:{} {} {}".format(hr, new, rem)
   if new:
      get_remain(new, rem)

get_remain(x, 0)
print hr
