n = gets.to_i 100.times do n = n.to_s.chars.map(&:to_i).reduce(:+) end p n