if __name__ == "__main__":
    good, for_good = map(int, raw_input().split())
    bad = 0
    hours = 0
    while good > 0:
        hours += good
        bad += good
        good = bad / for_good
        bad %= for_good
    print hours