#include #include using namespace std; bool is_prime(size_t s) { if (s <= 1) return false; for (int i = 2; i < ::sqrt(s) + 1; i++) { if (s % i == 0) return false; } return true; } size_t max (set a){ size_t ans = 0; for (size_t i : a){ if (i > ans) ans = i; } return ans; } size_t count(size_t s) { if (s == 0) return 0; set ans; for (size_t i = 0, copy = s; copy > 0; i++, copy /= 10) { size_t ss = s; ss = ss / (size_t)pow(10, i + 1) * (size_t)pow(10, i) + ss % (size_t)pow(10, i); if (is_prime(ss)) ans.insert(1 + count(ss)); } return max(ans); } int main() { size_t s; cin >> s; if (!is_prime(s)) cout << 0; else cout << (count(s) + 1); return 0; }