#include using namespace std; using ll = long long; using Graph = vector >; #define rep(i, a, b) for(int i = a; i < b; i++) #define rrep(i, a, b) for(int i = a; i >= b; i--) #define fore(i, a) for(auto &i:a) #define all(x) (x).begin(),(x).end() const int INFI = 1 << 30; const ll INFL = 1LL << 60; int main() { cin.tie(0); ios::sync_with_stdio(false); ll s; cin >> s; vector A; while (s) { A.push_back(s % 10); s /= 10; } reverse(all(A)); int n = A.size(); auto is_prime = [](ll n) { if (n == 1) return 0; for (ll i = 2; i * i <= n; i++) { if (n % i == 0) return 0; } return 1; }; int ans = 0; rep(bit, 0, 1 << (n - 1)) { ll sum = 0; ll tmp = 0; rep(i, 0, n) { tmp += A[i]; if (bit & (1 << i)) { sum += tmp; tmp = 0; } else if (i == n-1) sum += tmp; else { tmp *= 10; } } ans += is_prime(sum); } cout << ans << "\n"; }