#include using namespace std; vector checkv(int bit, int N) { vector v(N); for(int i = 0; i < N; i++) if(bit & (1 << i)) v[i] = 1; return v; } int main() { string S; cin >> S; int s = (int)S.size(); if(s == 1) { if(S == "2" || S == "3" || S == "5" || S == "7") cout << 1 << endl; else cout << 0 << endl; return 0; } int64_t ans = 0; int64_t n; int64_t T; bool pos; for(int bit = 0; bit < (1 << (s - 1)); bit++) { vector C = checkv(bit, s - 1); n = 0; T = 0; for(int i = 0; i < s - 1; i++) { n *= 10; n += (int64_t)(S[i] - '0'); if(C[i] == 1) { T += n; n = 0; } } n *= 10; n += (int64_t)(S[s - 1] - '0'); T += n; pos = true; for(int64_t i = 2; i * i <= T; i++) { if(T % i == 0) { pos = false; break; } } if(pos) ans++; } cout << ans << endl; return 0; }