cho.sh
Notes
Loading...

Divisible by Its Digits

Time limit

2s

Memory limit

128 MB

Problem

You are given a positive integer NNN. Find the smallest integer whose decimal representation starts with NNN and that is divisible by every nonzero digit appearing in NNN.

Digits equal to 0 are ignored for the divisibility condition.

Input

The first line contains a positive integer NNN.

1≤N≤1,000,000,0001 \le N \le 1,000,000,0001≤N≤1,000,000,000

Output

Print the smallest integer satisfying the condition.