Problem:
Score : 700 points

Problem Statement

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

Constraints

2 \leq K \leq 10^5

K is an integer.

Input

Input is given from Standard Input in the following format:

K

Output

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

Sample Input 1

6

Sample Output 1

3

12=6×2 yields the smallest sum.

Sample Input 2

41

Sample Output 2

5

11111=41×271 yields the smallest sum.

Sample Input 3

79992

Sample Output 3

36

Solution in Rust (1.15.1) (judge verdict: Wrong Answer)

use std::io;

fn main(){
    let K=get_int() as u64;
    let Length=K.to_string().len();
    let mut Max=1 as u64;
    for i in 0..Length{
        Max*=10 as u64;
    }
    let mut Min:u64=K as u64;
    for i in 1..Max{
        Min=std::cmp::min(Min,get_sum(K*i));
    }
    println!("{}",Min);
}

fn get_sum(x :u64)->u64{
  let mut sum=0;
  for i in  x.to_string().chars(){
      sum+=i.to_digit(10).unwrap();
  }
  sum as u64
}

fn get_String()->String{
    let mut s =String::new();
    io::stdin().read_line(&mut s).expect("Fail!");        
    s.trim().to_string()
}

fn get_int()->i32{
    let mut input =String::new();
    io::stdin().read_line(&mut input).expect("Fail!");
    input.trim().to_string().parse().unwrap()
}



fn get_inputs<'a,'b>(S:&'a String, v:&'b mut Vec<&'a str>) {
    for key in S.split(' '){
        v.push(key);
    }
}