#include #define ff first #define ss second #define ll long long using namespace std; #define all(x) x.begin(), x.end() using u64 = uint64_t; using u128 = __uint128_t; u64 binpower(u64 base, u64 e, u64 mod) { u64 result = 1; base %= mod; while (e) { if (e & 1) result = (u128)result * base % mod; base = (u128)base * base % mod; e >>= 1; } return result; } bool check_composite(u64 n, u64 a, u64 d, int s) { u64 x = binpower(a, d, n); if (x == 1 || x == n - 1) return false; for (int r = 1; r < s; r++) { x = (u128)x * x % n; if (x == n - 1) return false; } return true; }; bool MillerRabin(u64 n) { if (n < 2) return false; int r = 0; u64 d = n - 1; while ((d & 1) == 0) { d >>= 1; r++; } for (int a : {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37}) { if (n == a) return true; if (check_composite(n, a, d, r)) return false; } return true; } void solve() { string s; cin >> s; int n = s.length(), ans = 0; for (int i = 0, en = 1 << (n - 1); i < en; i++) { ll p = 0; string t = string(1, s[0]); for (int j = 0; j < n - 1; j++) { if ((i >> j) & 1) { t += s[j + 1]; } else { p += stoll(t), t = s[j + 1]; } } p += stoll(t); if (MillerRabin(p)) ans++; } cout << ans << '\n'; } int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); solve(); return 0; }