#P1150. Peter's Cigarette Problem

    ID: 13585 Type: Default 1000ms 256MiB

Peter's Cigarette Problem

Peter's Cigarette Problem

Peter has $n$ cigarettes. He smokes them one by one and saves each butt. Every time he accumulates $k$ butts (with $k>1$), he can exchange them for one new cigarette. However, unlike some brainteasers, Peter cannot borrow cigarettes or butts from another dimension. Determine the total number of cigarettes he can smoke.

inputFormat

The input consists of two integers: $n$ (the initial number of cigarettes) and $k$ (the number of butts required to exchange for one new cigarette).

outputFormat

Output a single integer representing the total number of cigarettes Peter can smoke.

sample

10 3
14