b = gets.to_i 99.times do sum = 0 for c in b.to_s.split('') sum += c.to_i end b = sum end p b