eolymp
bolt
Try our new interface for solving problems
Problems

Happy Camper

Happy Camper

As Happy Camper Harry pulls into his favorite campground with his family, he notices the sign: 'Campground occupancy is limited to 5 days within any consecutive 8-day period.' Harry is just starting a 20-day vacation. What is the maximum number of days he can occupy a campsite during his vacation?

We state the problem in more general terms. Suppose that l, p, v (1 < l < p < v) are integers. Campground occupancy is limited to l days within any consecutive p-day period. Happy Camper Harry is just starting a v-day vacation. What is the maximum number of days he can occupy a campsite during his vacation?

prb7548.gif

Input

Contains multiple test cases. For each test case, there will be one line of data, containing values of l, p and v, in that order. All integers can be represented by signed 32-bit integers. End of data will be signaled by a line containing three zeros, which will not be processed.

Output

For each test case print one line. It will display the case number and the number of days Happy Camper Harry can occupy a campsite during his vacation. The format is illustrated by the sample output.

Time limit 1 second
Memory limit 128 MiB
Input example #1
5 8 20
5 8 17
0 0 0
Output example #1
Case 1: 14
Case 2: 11
Source 2012 ACM North America - Rocky Mountain, Problem A