str=gets.chomp def is_number?(str1) return true if str1 == "0" return (str1.to_i > 0 and str1.to_i < 10) end def plusall(s1) total = 0 for num in 0..s1.length if is_number?(s1[num, 1]) total += s1[num, 1].to_i end end puts total end puts plusall(str)