eolymp
bolt
Try our new interface for solving problems
Problems

Faulty Mars Rover

Faulty Mars Rover

Time limit 1 second
Memory limit 128 MiB

The Mars rover, carrying out an international mission on Mars, is faulty. To restore its performance, it is necessary to increase the capacity of its battery.

The battery power of the rover is a positive integer. The current battery capacity is a, to restore the performance of the rover, it is necessary to increase its power to b. To change the battery power to the Mars rover from the Earth, you can send special signals of two types: X and Y. X type signal increases the current battery capacity by 1, and Y type signal increases the current battery capacity by 2.

The mission organisers would like to change the battery capacity to the required level by transmitting the minimum number of signals. Unfortunately, due to the peculiarity of the device of the rover, if the battery power is a multiple to an integer c, it finally fails and stops responding to signals.

Write a program that, given the initial power of the battery a, the required battery power b and the integer c, determines the minimum number of signals that need to be transmitted to the rover to restore its operation.

Input data

Three integers a, b and c, one in a line (1a < b10^9, 2c10^9, a is not divisible by c, b is not divisible by c).

Output data

Print one integer: the minimum number of signals that must be transmitted to the rover.

Examples

Input example #1
2
7
3
Output example #1
3
Input example #2
4
10
3
Output example #2
4

Note

In the first example, you can act as follows: send signals to the rover Y, X, Y. Battery power varies as follows: 2457.

In the second example, you can act as follows: send signals to the rover X, Y, X, Y. Battery power varies as follows: 457810.

Source 2019 All-Russia Informatics School Olympiad, Regional stage, Day 2, Moscow, January 28, Problem А