def main():
    a, b = tuple(int(s) for s in raw_input().split())
    answer, rem = 0, 0
    while a > 0:
        answer += a
        rem += a
        a = rem / b
        rem = rem % b

    print answer


if __name__ == '__main__':
    main()