s = gets.chomp a = s.gsub(/[^\d]/, "") s = a.chars.map(&:to_i) puts s.inject(:+)