eolymp
bolt
Try our new interface for solving problems
Problems

Ordered numbers

Ordered numbers

Misha has a developed aesthetic feeling. He believes that not all numbers are equally ordered. When he is sad, he begins to invent numbers and put them in order.

Misha likes to consider the sum of digits of a number. In order to put in order a number a, he first writes the number itself. Then he writes the sum of the digits of this number. Then the sum of digits of the sum of digits, and so on, until the next number becomes one-digit number. He believes that the result of putting the number a in order is the sum of all the numbers written out, including the number a itself.

Misha loves this process so much that he even replaces his sheep count with it when he cannot sleep for a long time. He remembers that last night, when he put the number a in order in his mind, he got the number b. But the trouble is - he doesn't remember which number a he took! Help him to find this number.

Input

One positive integer b (1b109).

Output

If there exists such number a, that after putting it in order, it becomes b, then output any such number. If Misha somewhere was mistaken in the calculations and such number does not exist, print -1.

Time limit 1 second
Memory limit 128 MiB
Input example #1
42
Output example #1
29
Input example #2
20
Output example #2
-1
Source 2013 Moscow city informatics olympiad for 6-9 classes, Moscow, February 3, Problem B