Under construction

Still being built. Things may change

Carbonated Drinks

Interview

Time limit1sMemory limit128 MB

Summary
Given starting empties, empties found, and the empties needed per exchange, count how many drinks Junmin can obtain and drink in total.
Level

Easy3 of 10

Topics
Math, Simulation, Implementation, Greedy
Solved
No attempts yet

Problem

Junmin loves carbonated drinks. However, he spent all of his money buying drinks, so right now he has no money at all and cannot buy any new ones.

Junmin is a law-abiding person, so no matter how badly he craves a carbonated drink, he will never steal one. He will only obtain drinks through legal means.

As it happens, there is an event running: if you bring in a fixed number of empty bottles, they are exchanged for one new bottle of drink. Junmin diligently collects empty bottles from the street and then uses this event to drink carbonated drinks.

After he finishes one bottle, one empty bottle is left over, and that empty bottle can be used for another exchange as well.

Given the number of empty bottles Junmin already had, the number of empty bottles he collected from the street, and the number of empty bottles required to exchange for one new bottle, write a program that finds how many carbonated drinks Junmin can drink in total.

Input

The first line contains the number of empty bottles Junmin already had ee, the number of empty bottles he collected that day ff, and the number of empty bottles required to exchange for one new bottle cc, separated by spaces. (0≤e<10000 \le e < 1000, 0≤f<10000 \le f < 1000, 1<c<20001 < c < 2000) ee, ff, and cc are all non-negative integers.

Output

On the first line, print how many carbonated drinks Junmin can drink.

Examples2

  1. Example 1

    Input
    9 0 3
    
    Expected output
    4
    
  2. Example 2

    Input
    5 5 2
    
    Expected output
    9