import itertools S = input() ans = 0 for t in itertools.product((0, 1), repeat=(len(S) - 1)): N = S[0] for i, u in enumerate(t, 1): if u: N += "+" N += S[i] x = eval(N) for y in range(2, int(x ** .5) + 1): if not x % y: break else: if x != 1: ans += 1 print(ans)