Magic Multiple#6975

Magic Multiple

1 second
128 megabytes
Medium

The Elvish races of Middle Earth believed that certain numbers were more significant than others. When using a particular quantity of metal to forge a particular sword, they believed that sword would be most powerful if the thickness were chosen according to the following rule:

Given a nonnegative integer , what is the smallest such that the decimal representations of the integers in the sequence:

n, 2n, 3n, 4n, 5n, \ldots, kn

contain all ten digits ( through ) at least once?

Lord Elrond of Rivendell has commissioned you with the task to develop an algorithm to find the optimal thickness () for any given quantity of metal ().

Input

Input will consist of a single integer (1 \le n \le 200000000) per line.

Output

The output will consist of a single integer per line, indicating the value of needed such that every digit from through is seen at least once.

Examples

Example 1

Loading
Loading