n = gets.to_s result = 0 n.each_char do |char| temp = char.ord - 48 if 0 <= temp && temp <= 9 result += temp end end puts result