def is_prime(n):# O(√N) if n == 1: return True for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True s = input() keta = len(s)-1 ans = 0 for i in range(2**keta): tmp = format(i,"0"+str(keta)+"b") num = int(s[0]) val = 0 for j in range(keta): if tmp[j] == "0": num *= 10 num += int(s[j+1]) else: val += num num = int(s[j+1]) val += num if is_prime(val): ans += 1 print(ans)