#include #include #include using namespace std; bool isPrime(int N) { if (N==1 || N==0) return false; for (int i = 2; i <= sqrt(N); i++) { if (N % i == 0) { return false; } } return true; } int countDigits(int N) { int count = 1; while(N > 10) { N = N / 10; count++; } return count; } int removeDigit(int N, int pos) { return N / int(pow(10, pos + 1)) * int(pow(10, pos)) + N % int(pow(10, pos)); } int mink(int N, bool initial) { if (!initial && !isPrime(N)) return 0; if (N < 10) { if (isPrime(N)) return 1; return 0; } else { int cmax = 0; for(int i = 0; i < countDigits(N); i++) { int current = mink(removeDigit(N, i), false) + isPrime(N); if(current > cmax) cmax = current; } return cmax; } } int main() { int N; cin >> N; cout << mink(N, true) << endl; }