#abc255c. [abc255_c]±1 Operation 1
[abc255_c]±1 Operation 1
Problem Statement
You are given an integer . The following action on this integer is called an operation.
- Choose and do one of the following.
- Add to .
- Subtract from .
The terms in the arithmetic progression with terms whose initial term is and whose common difference is are called good numbers.
Consider performing zero or more operations to make a good number. Find the minimum number of operations required to do so.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer as an integer.
Sample Input 1
6 2 3 3
Sample Output 1
1
Since , we have .
You can subtract from once to make a good number.
It is impossible to make good in zero operations.
Sample Input 2
0 0 0 1
Sample Output 2
0
We might have . Additionally, no operation might be required.
Sample Input 3
998244353 -10 -20 30
Sample Output 3
998244363
Sample Input 4
-555555555555555555 -1000000000000000000 1000000 1000000000000
Sample Output 4
444445