use std::cmp::*; use std::collections::*; use std::io::*; use std::str::FromStr; fn read() -> T { let stdin = stdin(); let stdin = stdin.lock(); let token: String = stdin .bytes() .map(|c| c.expect("failed to read char") as char) .skip_while(|c| c.is_whitespace()) .take_while(|c| !c.is_whitespace()) .collect(); token.parse().ok().expect("failed to parse token") } fn main(){ let mut n:i64 = read(); let mut tmp:i64 = 0; while n / 10 > 0 { let mut k = n; while(k > 0){ tmp += k % 10; k /= 10; } n = tmp; tmp = 0; } println!("{}",n); }