import math s = input() n = len(s) ans = 0 for mask in range(1 << (n - 1)): q = [] cnt = 0 for i in range(n): cnt = cnt * 10 + int(s[i]) if (mask >> i) & 1 != 0: q.append(cnt) cnt = 0 q.append(cnt) num = sum(q) if num >= 2 and all([num % x != 0 for x in range(2, int(math.sqrt(num)) + 1)]): ans += 1 print(ans)