use std::io::Read; fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let n: u128 = itr.next().unwrap().parse().unwrap(); let m: u128 = itr.next().unwrap().parse().unwrap(); for i in 0..18 { let num: u128 = n * 10u128.pow(i); if num % m == 0 { let mut ans = num / m; while ans % 10 == 0 { ans /= 10; } println!("{}", ans % 10); return; } } println!("-1"); }