fn main() { let mut n = String::new(); std::io::stdin().read_line(&mut n).ok(); let mut n: u64 = n.trim().parse().unwrap(); for _ in 0..99 { let mut next_n = 0; while n > 0 { next_n += n % 10; n /= 10; } n = next_n; if n < 10 { break; } } println!("{}", n); }