N = gets.to_i ans = N 100.times do ans = ans.digits.sum end puts ans