""" """ import sys from sys import stdin def is_prime(x): if x == 1: return False for y in range(2,10**10): if y**2 > x: break if x % y == 0: return False return True S = list(map(int, list(input()) )) N = len(S) ans = 0 for i in range(2**(N-1)): s = 0 now = S[0] for j in range(N-1): if 2**j & i > 0: now *= 10 now += S[j+1] else: s += now now = S[j+1] s += now if is_prime(s): ans += 1 print (ans)