require "prime" require "set" S = gets.chomp.chars.map(&:to_i) N = S.size ans = 0 (1 << N - 1).times do |bits| a = [S[0]] (1 ... N).each do |i| a << 0 if bits[i - 1] == 1 a[-1] = a[-1] * 10 + S[i] end ans += 1 if a.sum.prime? end puts ans