cho.sh
Notes
Loading...

Decomposition Sum

Time limit

2s

Memory limit

192 MB

Problem

The decomposition sum of a natural number N is N plus the sum of its decimal digits. If the decomposition sum of a natural number M is N, then M is called a constructor of N. For example, the decomposition sum of 245 is 245 + 2 + 4 + 5 = 256, so 245 is a constructor of 256. Some natural numbers have no constructor, and some have more than one.

Given a natural number N, write a program that finds the smallest constructor of N.

Input

The first line contains a natural number N (1 <= N <= 1,000,000).

Output

Print the answer on the first line. If N has no constructor, print 0.