#K38677. Total Candle Count Calculation

    ID: 26252 Type: Default 1000ms 256MiB

Total Candle Count Calculation

Total Candle Count Calculation

You are given an initial number of candles k and an integer a representing the amount of wax required to form one new candle. Every time a candle burns, it produces exactly one unit of wax. If you collect a units of wax, you can remold them into a new candle which will also burn and produce wax. Your task is to calculate the total number of candles that can be burned including those that are remolded from the wax.

Formally, let \( k \) be the initial number of candles and \( a \) be the number of wax units needed for a new candle. Initially, you have \( k \) candles. When a candle burns, it produces one unit of wax. Whenever you have accumulated at least \( a \) units of wax, you can form a new candle. This process continues until you can no longer form a new candle.

Note: All formulas are in \( \LaTeX \) format. For instance, the condition to form a new candle is given by:

[ \text{if } \text{leftover wax} \geq a, \text{ then form } \left\lfloor \frac{\text{leftover wax}}{a} \right\rfloor \text{ new candles.} ]

inputFormat

The input consists of a single line containing two space-separated integers \( k \) and \( a \), where \( k \) is the initial number of candles and \( a \) is the amount of wax required to form a new candle.

Constraints: \(1 \leq k \leq 10^9\), \(2 \leq a \leq 10^9\).

outputFormat

Output a single integer representing the total number of candles that can be burned.

## sample
9 3
13

</p>