#include using namespace std; struct iofast_t { iofast_t() { ios::sync_with_stdio(false); cin.tie(nullptr); } } iofast; struct uns_t {} uns; template auto vec(Element init, Head arg, Args ...args) { if constexpr (sizeof...(Args) == 0) return std::vector(arg, init); else return std::vector(arg, vec(init, args...)); } template auto vec(uns_t, Head arg, Args ...args) { return vec(Element(), arg, args...); } template > T &chmin(T &l, T r, Compare &&f = less()) { return l = min(l, r, f); } template > T &chmax(T &l, T r, Compare &&f = less()) { return l = max(l, r, f); } int main() { string s; cin >> s; auto is_prime = [](int64_t x) { for (int i = 2; i <= x / i; ++i) { if (x % i == 0) { return false; } } return true; }; int ans = 0; for (int i = 0; i < (1 << (size(s) - 1)); ++i) { int64_t sum = 0, sub = 0; for (int j = 0; j < size(s); ++j) { sub *= 10; sub += s[j] - '0'; if (i & (1 << j)) { sum += sub; sub = 0; } } sum += sub; ans += is_prime(sum); } cout << ans << endl; }