Difference from Reversal

Find the smallest nonnegative integer x whose value minus its decimal reversal equals a given natural number D, or report that none exists.

Medium7MathBrute forceNumber theoryImplementationNo attempts yetTime limit2sMemory limit128 MB

Problem

For a nonnegative integer, define its reversal as the integer obtained by reading its decimal digits from right to left. Any zeros that become leading zeros after the reversal disappear when the value is interpreted as an integer.

Given a natural number D, find the smallest nonnegative integer x such that x - reverse(x) = D. Here, reverse(x) denotes the reversal of x.

Input

D is given. D is a natural number not greater than 1,000,000.

Output

Print the smallest x satisfying the condition. If no such x exists, print -1.