import sys input = lambda: sys.stdin.readline().rstrip() def is_prime(n: int) -> bool: if n == 1: return 0 for i in range(2, int(n**0.5)+1): if n % i == 0: return 0 return 1 ############### s = input() n = len(s) ans = 0 for i in range(1 << (n-1)): seq = '' for j in range(n-1): if i >> j & 1: seq += '+' else: seq += ' ' tmp = s[0] for i in range(n-1): if seq[i] != ' ': tmp += seq[i] tmp += s[i+1] ans += is_prime(eval(tmp)) print(ans)