# def solution(sizes):
# answer = 0
# for i in range(len(sizes)):
# if sizes[i][0] < sizes[i][1]:
# t = sizes[i][0]
# sizes[i][0] = sizes[i][1]
# sizes[i][1] = t
# p = 0
# q = 0
# for i in range(len(sizes)):
# if sizes[i][0] > p:
# p = sizes[i][0]
# if sizes[i][1] > q:
# q = sizes[i][1]
# answer = p * q
# return answer
#
#
# d = list(map(int, input().split()))
# k = []
# for i in range(len(d) // 2):
# v = [d[2 i], d[2 i + 1]]
# k.append(v)
# print(solution(k))
# def solution(answers):
# answer = []
# s1 = 0
# s2 = 0
# s3 = 0
# for i in range(len(answers)):
# if answers[i] == i % 5 + 1:
# s1 += 1
# if i % 2 == 0 and answers[i] == 2:
# s2 += 1
# elif i % 2 == 1:
# if i % 8 < 4 and i % 8 == answers[i]:
# s2 += 1
# elif (i % 8 == 5 and answers[i] == 4) or (i % 8 == 7 and answers[i] == 5):
# s2 += 1
# if i % 10 < 2 and answers[i] == 3:
# s3 += 1
# elif 1 < i % 10 < 4 and answers[i] == 1:
# s3 += 1
# elif 3 < i % 10 < 6 and answers[i] == 2:
# s3 += 1
# elif 5 < i % 10 < 8 and answers[i] == 4:
# s3 += 1
# elif 7 < i % 10 < 10 and answers[i] == 5:
# s3 += 1
# if s1 > s2:
# if s1 > s3:
# answer.append(1)
# elif s1 == s3:
# answer.append(1)
# answer.append(3)
# else:
# answer.append(3)
# elif s1 == s2:
# if s1 > s3:
# answer.append(1)
# answer.append(2)
# elif s1 == s3:
# answer.append(1)
# answer.append(2)
# answer.append(3)
# else:
# answer.append(3)
# else:
# if s2 > s3:
# answer.append(2)
# elif s2 == s3:
# answer.append(2)
# answer.append(3)
# else:
# answer.append(3)
# return answer
#
#
# d = list(map(int, input()))
# print(solution(d))
def prime(p):
t = 2
k = 1
if p < 2:
return 0
while t * t <= p:
if p % t == 0:
k = 0
break
t += 1
if k == 0:
print(k, p, t, p / t)
else:
print(k, p, t - 1, p / (t - 1))
return k
def solution(numbers):
answer = 0
k = len(numbers)
numb = [0] * k
for i in range(k):
numb[i] = ord(numbers[i]) - 48
numb.sort()
q = 0
for i in range(k):
if i > 0 and numb[i] == numb[i - 1]:
continue
if prime(numb[i]) == 1:
answer += 1
if k > 1:
for i1 in range(k):
if numb[i1] == 0:
continue
if i1 > 0 and numb[i1] == numb[i1 - 1]:
continue
q = numb[i1]
for i2 in range(k):
if i1 == i2 and ((i2 + 1 < k and numb[i2] != numb[i2 + 1]) or i2 + 1 == k):
continue
if i2 > 0 and numb[i2] == numb[i2 - 1]:
continue
q = 10 * q + numb[i2]
if prime(q) == 1:
answer += 1
q = q // 10
if k > 2:
for i1 in range(k):
if numb[i1] == 0:
continue
if i1 > 0 and numb[i1] == numb[i1 - 1]:
continue
q = numb[i1]
for i2 in range(k):
if i1 == i2 and ((i2 + 1 < k and numb[i2] != numb[i2 + 1]) or i2 + 1 == k):
continue
if i2 > 0 and numb[i2] == numb[i2 - 1]:
continue
q = 10 * q + numb[i2]
for i3 in range(k):
if i1 == i3 and ((i3 + 1 < k and numb[i3] != numb[i3 + 1]) or i3 + 1 == k):
continue
if i2 == i3 and ((i3 + 1 < k and numb[i3] != numb[i3 + 1]) or i3 + 1 == k):
continue
if i3 > 0 and numb[i3] == numb[i3 - 1]:
continue
q = 10 * q + numb[i3]
if prime(q) == 1:
answer += 1
q = q // 10
q = q // 10
if k > 3:
for i1 in range(k):
if numb[i1] == 0:
continue
if i1 > 0 and numb[i1] == numb[i1 - 1]:
continue
q = numb[i1]
for i2 in range(k):
if i1 == i2 and ((i2 + 1 < k and numb[i2] != numb[i2 + 1]) or i2 + 1 == k):
continue
if i2 > 0 and numb[i2] == numb[i2 - 1]:
continue
q = 10 * q + numb[i2]
for i3 in range(k):
if i1 == i3 and ((i3 + 1 < k and numb[i3] != numb[i3 + 1]) or i3 + 1 == k):
continue
if i2 == i3 and ((i3 + 1 < k and numb[i3] != numb[i3 + 1]) or i3 + 1 == k):
continue
if i3 > 0 and numb[i3] == numb[i3 - 1]:
continue
q = 10 * q + numb[i3]
for i4 in range(k):
if i1 == i4 and ((i4 + 1 < k and numb[i4] != numb[i4 + 1]) or i4 + 1 == k):
continue
if i2 == i4 and ((i4 + 1 < k and numb[i4] != numb[i4 + 1]) or i4 + 1 == k):
continue
if i3 == i4 and ((i4 + 1 < k and numb[i4] != numb[i4 + 1]) or i4 + 1 == k):
continue
if i4 > 0 and numb[i4] == numb[i4 - 1]:
continue
q = 10 * q + numb[i4]
if prime(q) == 1:
answer += 1
q = q // 10
q = q // 10
q = q // 10
if k > 4:
for i1 in range(k):
if numb[i1] == 0:
continue
if i1 > 0 and numb[i1] == numb[i1 - 1]:
continue
q = numb[i1]
for i2 in range(k):
if i1 == i2 and ((i2 + 1 < k and numb[i2] != numb[i2 + 1]) or i2 + 1 == k):
continue
if i2 > 0 and numb[i2] == numb[i2 - 1]:
continue
q = 10 * q + numb[i2]
for i3 in range(k):
if i1 == i3 and ((i3 + 1 < k and numb[i3] != numb[i3 + 1]) or i3 + 1 == k):
continue
if i2 == i3 and ((i3 + 1 < k and numb[i3] != numb[i3 + 1]) or i3 + 1 == k):
continue
if i3 > 0 and numb[i3] == numb[i3 - 1]:
continue
q = 10 * q + numb[i3]
for i4 in range(k):
if i1 == i4 and ((i4 + 1 < k and numb[i4] != numb[i4 + 1]) or i4 + 1 == k):
continue
if i2 == i4 and ((i4 + 1 < k and numb[i4] != numb[i4 + 1]) or i4 + 1 == k):
continue
if i3 == i4 and ((i4 + 1 < k and numb[i4] != numb[i4 + 1]) or i4 + 1 == k):
continue
if i4 > 0 and numb[i4] == numb[i4 - 1]:
continue
q = 10 * q + numb[i4]
for i5 in range(k):
if i1 == i5 and ((i5 + 1 < k and numb[i5] != numb[i5 + 1]) or i5 + 1 == k):
continue
if i2 == i5 and ((i5 + 1 < k and numb[i5] != numb[i5 + 1]) or i5 + 1 == k):
continue
if i3 == i5 and ((i5 + 1 < k and numb[i5] != numb[i5 + 1]) or i5 + 1 == k):
continue
if i4 == i5 and ((i5 + 1 < k and numb[i5] != numb[i5 + 1]) or i5 + 1 == k):
continue
if i5 > 0 and numb[i5] == numb[i5 - 1]:
continue
q = 10 * q + numb[i5]
if prime(q) == 1:
answer += 1
q = q // 10
q = q // 10
q = q // 10
q = q // 10
if k > 5:
for i1 in range(k):
if numb[i1] == 0:
continue
if i1 > 0 and numb[i1] == numb[i1 - 1]:
continue
q = numb[i1]
for i2 in range(k):
if i1 == i2 and ((i2 + 1 < k and numb[i2] != numb[i2 + 1]) or i2 + 1 == k):
continue
if i2 > 0 and numb[i2] == numb[i2 - 1]:
continue
q = 10 * q + numb[i2]
for i3 in range(k):
if i1 == i3 and ((i3 + 1 < k and numb[i3] != numb[i3 + 1]) or i3 + 1 == k):
continue
if i2 == i3 and ((i3 + 1 < k and numb[i3] != numb[i3 + 1]) or i3 + 1 == k):
continue
if i3 > 0 and numb[i3] == numb[i3 - 1]:
continue
q = 10 * q + numb[i3]
for i4 in range(k):
if i1 == i4 and ((i4 + 1 < k and numb[i4] != numb[i4 + 1]) or i4 + 1 == k):
continue
if i2 == i4 and ((i4 + 1 < k and numb[i4] != numb[i4 + 1]) or i4 + 1 == k):
continue
if i3 == i4 and ((i4 + 1 < k and numb[i4] != numb[i4 + 1]) or i4 + 1 == k):
continue
if i4 > 0 and numb[i4] == numb[i4 - 1]:
continue
q = 10 * q + numb[i4]
for i5 in range(k):
if i1 == i5 and ((i5 + 1 < k and numb[i5] != numb[i5 + 1]) or i5 + 1 == k):
continue
if i2 == i5 and ((i5 + 1 < k and numb[i5] != numb[i5 + 1]) or i5 + 1 == k):
continue
if i3 == i5 and ((i5 + 1 < k and numb[i5] != numb[i5 + 1]) or i5 + 1 == k):
continue
if i4 == i5 and ((i5 + 1 < k and numb[i5] != numb[i5 + 1]) or i5 + 1 == k):
continue
if i5 > 0 and numb[i5] == numb[i5 - 1]:
continue
q = 10 * q + numb[i5]
for i6 in range(k):
if i1 == i6 and ((i6 + 1 < k and numb[i6] != numb[i6 + 1]) or i6 + 1 == k):
continue
if i2 == i6 and ((i6 + 1 < k and numb[i6] != numb[i6 + 1]) or i6 + 1 == k):
continue
if i3 == i6 and ((i6 + 1 < k and numb[i6] != numb[i6 + 1]) or i6 + 1 == k):
continue
if i4 == i6 and ((i6 + 1 < k and numb[i6] != numb[i6 + 1]) or i6 + 1 == k):
continue
if i5 == i6 and ((i6 + 1 < k and numb[i6] != numb[i6 + 1]) or i6 + 1 == k):
continue
if i6 > 0 and numb[i6] == numb[i6 - 1]:
continue
q = 10 * q + numb[i6]
if prime(q) == 1:
answer += 1
q = q // 10
q = q // 10
q = q // 10
q = q // 10
q = q // 10
if k > 6:
for i1 in range(k):
if numb[i1] == 0:
continue
if i1 > 0 and numb[i1] == numb[i1 - 1]:
continue
q = numb[i1]
for i2 in range(k):
if i1 == i2 and ((i2 + 1 < k and numb[i2] != numb[i2 + 1]) or i2 + 1 == k):
continue
if i2 > 0 and numb[i2] == numb[i2 - 1]:
continue
q = 10 * q + numb[i2]
for i3 in range(k):
if i1 == i3 and ((i3 + 1 < k and numb[i3] != numb[i3 + 1]) or i3 + 1 == k):
continue
if i2 == i3 and ((i3 + 1 < k and numb[i3] != numb[i3 + 1]) or i3 + 1 == k):
continue
if i3 > 0 and numb[i3] == numb[i3 - 1]:
continue
q = 10 * q + numb[i3]
for i4 in range(k):
if i1 == i4 and ((i4 + 1 < k and numb[i4] != numb[i4 + 1]) or i4 + 1 == k):
continue
if i2 == i4 and ((i4 + 1 < k and numb[i4] != numb[i4 + 1]) or i4 + 1 == k):
continue
if i3 == i4 and ((i4 + 1 < k and numb[i4] != numb[i4 + 1]) or i4 + 1 == k):
continue
if i4 > 0 and numb[i4] == numb[i4 - 1]:
continue
q = 10 * q + numb[i4]
for i5 in range(k):
if i1 == i5 and ((i5 + 1 < k and numb[i5] != numb[i5 + 1]) or i5 + 1 == k):
continue
if i2 == i5 and ((i5 + 1 < k and numb[i5] != numb[i5 + 1]) or i5 + 1 == k):
continue
if i3 == i5 and ((i5 + 1 < k and numb[i5] != numb[i5 + 1]) or i5 + 1 == k):
continue
if i4 == i5 and ((i5 + 1 < k and numb[i5] != numb[i5 + 1]) or i5 + 1 == k):
continue
if i5 > 0 and numb[i5] == numb[i5 - 1]:
continue
q = 10 * q + numb[i5]
for i6 in range(k):
if i1 == i6 and ((i6 + 1 < k and numb[i6] != numb[i6 + 1]) or i6 + 1 == k):
continue
if i2 == i6 and ((i6 + 1 < k and numb[i6] != numb[i6 + 1]) or i6 + 1 == k):
continue
if i3 == i6 and ((i6 + 1 < k and numb[i6] != numb[i6 + 1]) or i6 + 1 == k):
continue
if i4 == i6 and ((i6 + 1 < k and numb[i6] != numb[i6 + 1]) or i6 + 1 == k):
continue
if i5 == i6 and ((i6 + 1 < k and numb[i6] != numb[i6 + 1]) or i6 + 1 == k):
continue
if i6 > 0 and numb[i6] == numb[i6 - 1]:
continue
q = 10 * q + numb[i6]
for i7 in range(k):
if i1 == i7 and ((i7 + 1 < k and numb[i7] != numb[i7 + 1]) or i7 + 1 == k):
continue
if i2 == i7 and ((i7 + 1 < k and numb[i7] != numb[i7 + 1]) or i7 + 1 == k):
continue
if i3 == i7 and ((i7 + 1 < k and numb[i7] != numb[i7 + 1]) or i7 + 1 == k):
continue
if i4 == i7 and ((i7 + 1 < k and numb[i7] != numb[i7 + 1]) or i7 + 1 == k):
continue
if i5 == i7 and ((i7 + 1 < k and numb[i7] != numb[i7 + 1]) or i7 + 1 == k):
continue
if i6 == i7 and ((i7 + 1 < k and numb[i7] != numb[i7 + 1]) or i7 + 1 == k):
continue
if i7 > 0 and numb[i7] == numb[i7 - 1]:
continue
q = 10 * q + numb[i7]
if prime(q) == 1:
answer += 1
q = q // 10
q = q // 10
q = q // 10
q = q // 10
q = q // 10
q = q // 10
return answer
d = list(input())
print(solution(d))