F. Fragment
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Vasya calculates the sum 2+22+202+2002+...20...02 and wants to see his lucky four-digit number $$$N$$$ among the consecutive digits of the resulting sum. Help Vasya determine the minimum number of summands he needs to take in order to have a fragment in the decimal representation of the sum that coincides with his lucky number $$$N$$$.

Input

An integer $$$N$$$ is entered ($$$1000 \le N \le 9999$$$).

Output

Output the minimum number of summands whose sum will allow Vasya to see a fragment in the form of his lucky number, if possible. Otherwise, output -1.

Examples
Input
2230
Output
5
Input
2023
Output
49005