#素数判定 for long long def Is_Prime_for_long_long(N): if N<=1: return False if N==2 or N==7 or N==61: return True if N%2==0: return False d=N-1 while d%2==0: d//=2 for a in (2,7,61): t=d y=pow(a,t,N) while t!=N-1 and y!=1 and y!=N-1: y=(y*y)%N t<<=1 if y!=N-1 and t%2==0: return False return True #================================================== from itertools import product S=input() N=len(S) K=0 for p in product((0,1),repeat=N-1): X=0; Y=int(S[0]) for i in range(N-1): if p[i]==0: Y*=10; Y+=int(S[i+1]) else: X+=Y Y=int(S[i+1]) X+=Y if Is_Prime_for_long_long(X): K+=1 print(K)