def prime_factorize(n): a = [] while n % 2 == 0: a.append(2) n //= 2 f = 3 while f * f <= n: while n % f == 0: a.append(f) n //= f else: f += 2 if n != 1: a.append(n) return a s = list(map(int, input())) a = [(0, s[0])] for d in s[1:]: tmp = [] for p, q in a: tmp.append((p + q, d)) tmp.append((p, q * 10 + d)) a = tmp[:] ans = 0 for p, q in tmp: if len(prime_factorize(p + q)) == 1: ans += 1 print(ans)