Role-playing game
Vasya is organizing an inventory for a role-playing game that involves n players, each playing a character from a fantasy world. Each character will have a level x, which is an integer ranging from 1 to m.
To represent these levels, two types of tokens will be used: white and red. A white token signifies one level, while a red token signifies k levels. For a character with level x, the player must have a white tokens and b red tokens such that the equation (a + bk) equals x. Additionally, no character can have more than (k - 1) white tokens.
The tokens are prepared in advance, but the specific levels of the characters are unknown until the game begins. To ensure the game runs smoothly, each character must receive the correct number of tokens corresponding to their level. The challenge is to determine the minimum total number of tokens that need to be prepared to accommodate any possible character levels.
Your task is to write a program that calculates the minimum number of tokens required to ensure the game can be played successfully, given the values n, m, and k.
Input
The input consists of a single line containing three integers: n, m, and k (1 ≤ n ≤ 10^4, 1 ≤ m ≤ 10^5, 1 ≤ k ≤ 10^5).
Output
The output should be a single integer representing the minimum number of tokens that need to be prepared.