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

import sys

a, b = map(int, raw_input().split())
h = 0
old = 0

next = a
while 1:
    h += next
    old += next
    next = old / b
    old = old % b
    if next == 0:
        break

print h
