import numpy as np from itertools import product s = input() def seachPrimeNum(N): max = int(np.sqrt(N)) seachList = [i for i in range(2,N+1)] primeNum = [] while seachList[0] <= max: primeNum.append(seachList[0]) tmp = seachList[0] seachList = [i for i in seachList if i % tmp != 0] primeNum.extend(seachList) return primeNum ss = set(seachPrimeNum(999999999)) lens = len(s) bitl = list(product([False, True], repeat=lens-1)) ans = 0 for i in range(len(bitl)): eval_l = [] for j in range(lens-1): if bitl[i][j]: eval_l.append(s[j]) eval_l.append("+") else: eval_l.append(s[j]) eval_l.append(s[-1]) if eval("".join(eval_l)) in ss: ans += 1 print(ans)