#include #include #include #include #include #include #include #include #include #if __has_include() # include # include # include # include #endif #include #include #include #include #include #include #include #define CLIBCXX_DEBUG #define ll long long #define hmap unordered_map #define hset unordered_set using namespace std; #if __has_include() using namespace atcoder; using mint10 = static_modint<10>; using mint = modint998244353; #endif ll powll(ll a, ll b) { //制約 ans∊ll a, b∊double range return (ll)pow(a, b / 2) * (ll)pow(a, b - b / 2); } ll sum(ll a, ll b) { return a + b; } ll e() { return 0; } //return true if an argument is prime or one bool isPrime(double num, set& primes, set& comps){ if(num==1){ return false; } if(primes.find(num)!=primes.end()){ return true; } if(comps.find(num)!=comps.end()){ return false; } double sq = sqrtf64(num); for(int32_t i = 2; i <= sq; ++i){ if((ll)num%i==0){ comps.insert(num); return false; } } primes.insert(num); return true; } int main() { string s; cin >> s; ll cnt = 0; ll size = s.size(); set primes; set comps; auto isPrime = [](double num, set& primes, set& comps)->bool{ if(num==1){ return false; } if(primes.find(num)!=primes.end()){ return true; } if(comps.find(num)!=comps.end()){ return false; } double sq = sqrtf64(num); for(int32_t i = 2; i <= sq; ++i){ if((ll)num%i==0){ comps.insert(num); return false; } } primes.insert(num); return true; }; for(ll i = 0; i < (1<<(size-1)); ++i){ ll ans = 0; string sub = ""; ll j = 0; for(; j < size-1; ++j){ if(!(i>>j&1)){ sub+=s[j]; }else{ sub+=s[j]; //cout << sub << endl; ans+=stoll(sub); sub = ""; } } sub+=s[size-1]; //cout << sub << endl; ans+=stoll(sub); if(isPrime(ans,primes,comps)){ // cout << "regarded as prime:"<