#include using namespace std; typedef long long ll; bool is_prime(ll x) { if (x == 1) return false; for (ll i = 2; i*i <= x; i++) { if (x%i == 0) { return false; } } return true; } int solve(string s) { int n = s.size(); int ans = 0; for (int i = 0; i < (1<<(n-1)); i++) { ll sum = 0; string t = ""; for (int j = 0; j < n; j++) { if (j == n-1 || (i>>j)&1) { t += s[j]; sum += stoll(t); t = ""; } else { t += s[j]; } } ans += is_prime(sum); } return ans; } int main() { string s; cin >> s; cout << solve(s) << endl; return 0; }