TV#11688

TV

1 second
256 megabytes
Hard

At the moment, Barysh is watching channel on TV but wants to switch to channel b~(b > a) because an interesting football match is showing there. The TV remote is broken, only two buttons work. When one of these buttons is pressed, the TV switches to a channel with a number unit higher, and when the other button is pressed, the TV switches to a channel with a number units higher. Barysh wants to quickly switch to channel , pressing the minimum number of buttons, but there's a problem with channels whose numbers are exactly divisible by . When Barysh switches the TV to such a channel, the TV breaks.

What is the minimum number of button presses for Barysh to switch from channel number to channel number ?

Input

The first line contains an integer , the second line contains an integer b~(1 \le a < b \le 10^9), and the third line contains an integer c~(2 \le c \le 10^9). It is guaranteed that and are not divisible by .

Output

Print the minimum number of button presses for Barysh to switch from channel number to channel number .

Examples

In the first example, the transitions can be performed as follows: 2 → 4 → 5 → 7.

In the second example, the transitions can be performed as follows: 4 → 5 → 7 → 8 → 10.

Example 1

Loading
Loading

Example 2

Loading
Loading

Scoring

This problem consists of subtasks. Points for a subtask are awarded only if all the tests associated with that subtask are passed successfully.

  1. ( points): b, c \le 15;

  2. ( points): b, c \le 10^5;

  3. ( points): c = 2;

  4. ( points): no additional constraints;