s = gets.not_nil!.chomp sum = 0 s.each_char.select{|c| c >= '0' && c <= '9'}.each{|c| sum += c.to_i} puts sum