Олимпиадный тренинг

Задача 38266. counting crows


In the attic of a house in Prostokvashino, Sharik found a strange device. Uncle Fyodor quickly realized that it was — a manual mechanical counter, and according to his favorite encyclopedia, it is "a manual mechanism for counting repeated events by pressing a button on the counter, so as not to use pen and paper to write them down or not to keep these numbers in mind."

Inside, such a counter is arranged as follows: it has three disks with numbers from 0 to 9 inscribed on the edge. The disks are put on the axis to which the button is connected. Initially, the number 0 is written on each of the three disks. When the button is pressed, one or more disks are rotated so that the number currently recorded on the counter increases by 1. Each disk, when the button is pressed, rotates only one number forward. If several discs are rotated at the same time, the discs corresponding to the lower digits of the number are rotated first, and then — older.

For example, let's say the number 18 is written on the counter now. This means that the number 0 is set on the first disk, on the second — 1, on the third — 8. The next number after 18 — 19, so when the button is pressed, the third disk will rotate one number so that it is set to the number 9, and the rest will remain stationary. Now the counter will read 19. After pressing it again, the counter should show the number 20. This means that the third disk must be rotated by one number so that the number 0 is set on it, and that the second disk must also be rotated in order to 2 was installed on it.

In order to try his find in action, Sharik did not come up with anything better than to count the crows flying past the window. Since the counter that Ball found is very old, each of the dials will click when it is turned. Uncle Fyodor, who was sitting nearby, counted all the clicks that he heard. Now he wants to understand how many crows flew past their window, i.e. what number is written on the counter.

Input
One integer n is entered: how many clicks Uncle Fyodor counted (0<=n<=1107).

Imprint
Print one integer: the number of crows flying past the window. If Uncle Fyodor made a mistake and such a number of clicks couldn't have been made, print −1.
Examples
# Input Output
1 9 9
2 10 -1