- Time limit: 1.00 s
- Memory limit: 512 MB
You have a counter that initially shows the number . In one move you can either increase the counter by or decrease it by , but the counter can never be less than or more than . Find the minimum amount of moves you need in order to make the counter show or report that the task is impossible.
Input
The first line contains the integer .
Output
Print the minimum number of moves required to make the counter show or if the task is impossible.
Constraints
Example 1
Input:
62
Output:
8
Example 2
Input:
1
Output:
-1
Example 3
Input:
0
Output:
0