#include using namespace std; map res; int run(string s){ while(s[0] == '0'){ s.erase(s.begin()); } if(s.size() == 0){ return 0; } if(res.count(s)){ return res[s]; } int num = atoi(s.c_str()); bool prime = true; if(num == 1){ prime = false; } for(int i = 2; i*i<=num; ++i){ if(num%i == 0){ prime = false; } } if(!prime){ return res[s] = 0; } int _max = 0; for(int i = 0; i<(int)s.size(); ++i){ string news = s; news.erase(i, 1); _max = max(_max, run(news)); } return res[s] = _max+1; } int main(){ string s; cin >> s; cout << run(s) << "\n"; }