#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)] use { proconio::{marker::*, *}, std::*, std::{cmp::*, collections::*, convert::*, iter::*, marker::*, mem::*, ops::*}, }; fn main() { #![allow(unused, non_snake_case, dead_code, non_upper_case_globals)] let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr()); let mut io = IO::new(r.lock(), w.lock(), e.lock()); let s = io.read::(); println!("{}", dig(s)); } fn dig(n: i64) -> i64 { let mut m = n; let mut ret = 0; while m > 0 { ret += m % 10; m /= 10; } ret } static MX: usize = 1010101; static MOD: i64 = 1000000007; static INF: i64 = std::i64::MAX >> 1; use std::io::*; struct IO { Read: R, Write: BufWriter, Error: BufWriter, } impl IO { fn new(r: R, w: W, e: E) -> IO { IO { Read: r, Write: BufWriter::new(w), Error: BufWriter::new(e), } } fn read(&mut self) -> T where T: std::str::FromStr, { let next: String = self .Read .by_ref() .bytes() .map(|c| c.unwrap() as char) .skip_while(|c| c.is_whitespace()) .take_while(|c| !c.is_whitespace()) .collect(); next.parse().ok().unwrap() } fn chars(&mut self) -> Vec { self.read::().chars().collect() } fn chari(&mut self) -> Vec { self.chars() .iter() .map(|&c| (c as u8 - b'0') as i64) .collect::>() } fn readn(&mut self, n: usize) -> Vec { (0..n).map(|_| self.read::()).collect::>() } fn readmat(&mut self, n: usize, m: usize) -> Vec> { (0..n).map(|_| self.readn(m)).collect() } fn write(&mut self, val: S) { self.Write.write(val.to_string().as_bytes()); } fn writeln(&mut self, val: S) { self.Write.write(val.to_string().as_bytes()); self.Write.write(b"\n"); } fn debug(&mut self, val: S) { writeln!(self.Error, "(debug) {:?}", &val); } fn debug2(&mut self, val1: S, val2: T) { writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2); } fn debug3( &mut self, val1: S, val2: T, val3: U, ) { writeln!( self.Error, "(debug3) {:?} -> {:?} -> {:?}", val1, val2, val3 ); } }