from typing import DefaultDict S = list(input()) def is_prime(a): flag = True for i in range(2,int(a**0.5)+1): if a %i == 0: flag = False return flag def produce(Set): rev = 0 tmp = '' for i in range(len(S)): tmp += S[i] if (i in Set) or i == len(S)-1: rev += int(tmp) tmp = '' return rev cnt = 0 for i in range(1<<(len(S)-1)): Set = set() for k in range(len(S)-1): if (i>>k) & 1: Set.add(k) num = produce(Set) if is_prime(num): cnt += 1 print(cnt)