100 atcoder#ARC084B. [ABC077D] Small Multiple

[ABC077D] Small Multiple

Score : 700700 points

Problem Statement

Find the smallest possible sum of the digits in the decimal notation of a positive multiple of KK.

Constraints

  • 2K1052 \leq K \leq 10^5
  • KK is an integer.

Input

Input is given from Standard Input in the following format:

KK

Output

Print the smallest possible sum of the digits in the decimal notation of a positive multiple of KK.

6
3

12=6×212=6 \times 2 yields the smallest sum.

41
5

11111=41×27111111=41 \times 271 yields the smallest sum.

79992
36