#include using namespace std; using ll = long long; #define F first #define S second #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define sz(x) (int)(x).size() bool isprime(int x) { if (x <= 1) return false; for (int i = 2; i * i <= x; i++) { if (x % i == 0) return false; } return true; } int longest(string num) { if (num == "") return 0; int x = stoi(num); num = to_string(x); if (!isprime(x)) return 0; int ans = 1; for (int i = 0; i < sz(num); i++) { string res; for (int j = 0; j < i; j++) res += num[j]; for (int j = i+1; j < sz(num); j++) res += num[j]; ans = max(ans, 1 + longest(res)); } return ans; } void solve() { string num; cin >> num; cout << longest(num) << endl; } signed main() { solve(); }