#!/usr/bin/python

import sys

def read_obj(cls):
    return cls(sys.stdin.readline().strip())

def read_obj_list(cls):
    return map(cls, sys.stdin.readline().strip().split())

def solve():
    a, b = read_obj_list(int)
    rem = res = 0
    while a != 0:
        res += a
        rem += a
        a = rem / b
        rem %= b
    return res


if __name__ == "__main__":
    print solve()
