import sys
input = sys.stdin.readline
from collections import *

s = list(input()[:-1])
n = len(s)
ans = 0

for S in range(1<<(n-1)):
    num = 0
    now = 0
    
    for i in range(n):
        now = 10*now+int(s[i])
        
        if (S>>i)&1:
            num += now
            now = 0
    
    num += now
    
    if num==1:
        continue
    
    for i in range(2, int(num**0.5)+1):
        if num%i==0:
            break
    else:
        ans += 1

print(ans)