S = input() l = list(map(int,list(S))) C = 10 ** 6 dat = [0] * C prime = set() for i in range(2,C): if dat[i] == 0: prime.add(i) for j in range(2 * i,C,i): dat[j] = 1 import sys if len(S) == 1: if int(S) in prime: print(1) else: print(0) exit() N = len(S) - 1 ans = 0 for bit in range(1 << N): Sum = 0 now = l[0] for j in range(N): mask = 1 << j if mask & bit: Sum += now now = l[j+1] else: now = now * 10 + l[j+1] Sum += now if Sum in prime: ans += 1 print(ans)