require "prime" @s = gets.chomp def sol(cur) return [@s[cur]] if cur == @s.size-1 sol(cur+1).flat_map{|v| [@s[cur] + "+" + v, @s[cur] + v]} end puts sol(0).count{eval(_1).prime?}