def is_prime(n): if n <= 1: return False i = 2 while i * i <= n: if n % i == 0: return False i += 1 return True S = list(input()) N = len(S) - 1 ans = 0 for i in range(1 << N): now = S[0] L = [] for j in range(N): if (i >> j) & 1: L.append(int(now)) now = S[j + 1] else: now += S[j + 1] L.append(int(now)) if is_prime(sum(L)): ans += 1 print(ans)