tbl = [3, 2, 2, 2, 3, 2, 3, 2, 4, 3] p gets.chomp.chars.map{|c| if ('0'..'9').cover?(c) tbl[c.to_i] else 0 end }.inject(0,:+) + 1