CSES - Aalto Competitive Programming 2024 - wk12 - Wed - Counter
  • Time limit: 1.00 s
  • Memory limit: 512 MB

You have a counter that initially shows the number 00. In one move you can either increase the counter by 1111 or decrease it by 22, but the counter can never be less than 00 or more than xx. Find the minimum amount of moves you need in order to make the counter show xx or report that the task is impossible.

Input

The first line contains the integer xx.

Output

Print the minimum number of moves required to make the counter show xx or 1-1 if the task is impossible.

Constraints

  • 0x1060 \leq x \leq 10^6

Example 1

Input:

62

Output:

8

Example 2

Input:

1

Output:

-1

Example 3

Input:

0

Output:

0