fn main() { let mut n: usize = { let mut buf = String::new(); std::io::stdin().read_line(&mut buf).unwrap(); buf.trim_end().parse().unwrap() }; let f = |mut n: usize| -> usize { let mut res = 0; while n > 0 { res += n % 10; n /= 10; } res }; for _ in 0..99 { n = f(n); } println!("{}", n); }