def main():
    a,b = [int(c) for c in raw_input().split()]
    total = 0
    burnt = 0
    while a>0:
        total += a
        burnt += a
        a = burnt//b
        burnt %= b
    return total

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