a=gets.to_i;a = a.digits.sum while a > 9;p a