We need to compute the total number of hours we can have light given a initial new candles a and b conversion rate: b burnt candles can be turned into one new candle (which can be burned). This is classic "candle burning" problem: we have a candles, each burns for 1 hour and becomes a burnt candle. We can combine b burnt candles to get one new candle (which we can burn). Process continues until we have less than b burnt candles and no new candles left. Total hours = initial a + floor((a-1)/(b-1))? Actually classic problem: Given a, b, total = a + floor((a-1)/(b-1)). But let's derive.
We have a initial candles. After burning them all, we have a burnt candles. We can convert b burnt to 1 new. So effectively each new candle gives us 1 hour of light and also we get 1 burnt candle after burning. But the conversion reduces b burnt to 1 new, which when burned becomes 1 burnt. So net effect: using b burnt candles we get 1 hour of light and then we have 1 burnt candle leftover (from the new one). So effectively, each group of b burnt candles gives us an additional hour and leaves 1 burnt candle. So we can think of it as we start with a new candles (which are like "potential" light hours) and also some "stock" of burnt candles. Actually it's similar to the "soda bottles" problem: given initial a bottles, each bottle consumed gives 1 drink, and b empty bottles can be exchanged for 1 full bottle. The total number of drinks = a + floor((a-1)/(b-1)). But careful: In soda problem, you start with a full bottles. You drink them, get a empty bottles. You exchange b empty for 1 full. Then you drink it, get 1 empty, etc. So total drinks = a + (a-1)/(b-1) truncated? Actually known formula: total = a + floor((a-1)/(b-1)). For example: a=4, b=2 => total = 4 + floor(3/1)=7 correct. a=6, b=3 => total = 6 + floor(5/2)=6+2=8 correct. a=5, b=5 => total = 5 + floor(4/4)=5+1=6? Let's test manually: 5 candles -> burn 5 hours, 5 burnt. 5 can be turned into 1 new, burn it: 6th hour, leaves 1 burnt. Can't convert. So total 6, matches formula. a=1, b=2 => total = 1 + floor(0/1)=1 correct. a=2, b=2 => total = 2 + floor(1/1)=3 correct: burn 2 -> 2 burnt, convert 2 -> 1 new, burn -> 3rd hour. a=3, b=2 => total = 3 + floor(2/1)=5 correct? Burn 3 -> 3 burnt, convert 2 -> 1 new (remaining 1 burnt), burn new -> 4th hour, now have 1+1=2 burnt, convert 2->1 new, burn ->5th hour. Yes. So formula works for given constraints.
Thus solution: read a, b, compute total = a + (a-1)//(b-1). Print.
But careful when a < b? Then no conversion possible. total = a. Formula gives a + floor((a-1)/(b-1)). Since (a-1) < (b-1) for a <= b-1? Actually if a < b, then (a-1)/(b-1) < 1, floor 0, total = a. Good. If a = b? Then (a-1)/(b-1) = (b-1)/(b-1)=1, total = a+1? Let's test: a = b = 3. Burn 3 -> 3 burnt, convert 3 -> 1 new, burn -> 4th hour, left 1 burnt. So total 4. Formula gives 3 + floor(2/2)=3+1=4 correct. So fine.
Edge case b=1? But constraints b >= 2, so ignore.
Thus solution straightforward.
But we need to be careful with integer division.
Implementation:
a, b = map(int, input().split())
total = a + (a - 1) // (b - 1)
print(total)
Let's double-check for large values: a=1000, b=2 => total = 1000 + 999 = 1999. That's fine.
We should also note that the problem statement: "When Vasily lights up a new candle, it first burns for an hour and then it goes out." So each candle gives one hour.
Thus final answer.
But wait: There's nuance: "Vasily has a candles." Probably means a new candles initially. And he can make b went out candles into a new candle. So conversion rate b to 1. Yes.
So code as above.
Now I'll produce final answer. ```python
def main():
import sys
data = sys.stdin.read().strip().split()
if not data:
return
a, b = map(int, data)
total = a + (a - 1) // (b - 1)
print(total)
if name == "main":
main()