def isPrime(n): # nが素数か判定する if n == 0 or n == 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n ** 0.5) + 1, 2): if n % i == 0: return False return True S = input() N = len(S) ans = 0 for bin in range(1 << (N - 1)): total = 0 v = 0 for i in range(N): v = 10 * v + int(S[i]) if i < N - 1 and (bin >> i) & 1: total += v v = 0 total += v ans += isPrime(total) print(ans)