#include<bits/stdc++.h>
using namespace std;
bool ktsnt(int n) {
if(n < 2) return false;
if(n == 2) return true;
for(int i=2; i*i<=n; i++)
if(n % i == 0) return false;
return true;
}
bool isNumber(char ch) {
return (ch >= '0' && ch <= '9');
}
int main (){
string s; cin >> s;
int ans = 0;
for(int i=0; i<s.size(); i++) {
if(isNumber(s[i])) {
string so = "";
int j = i;
while(j < s.size() && isNumber(s[j])) {
so += s[j];
j++;
}
int num = 0, sz = so.size();
for(int i=sz-1; i>=0; i--)
num += pow(10, sz-i-1)*(so[i]-'0');
if(ktsnt(num)) ans = max(ans, num);
i = j-1;
}
}
cout << ans << '\n';
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKYm9vbCBrdHNudChpbnQgbikgewogICAgaWYobiA8IDIpIHJldHVybiBmYWxzZTsKICAgIGlmKG4gPT0gMikgcmV0dXJuIHRydWU7CiAgICBmb3IoaW50IGk9MjsgaSppPD1uOyBpKyspIAogICAgICAgIGlmKG4gJSBpID09IDApIHJldHVybiBmYWxzZTsKICAgIHJldHVybiB0cnVlOwp9CmJvb2wgaXNOdW1iZXIoY2hhciBjaCkgewogICAgcmV0dXJuIChjaCA+PSAnMCcgJiYgY2ggPD0gJzknKTsKfQppbnQgbWFpbiAoKXsKICAgIHN0cmluZyBzOyBjaW4gPj4gczsKICAgIGludCBhbnMgPSAwOwogICAgZm9yKGludCBpPTA7IGk8cy5zaXplKCk7IGkrKykgewogICAgICAgIGlmKGlzTnVtYmVyKHNbaV0pKSB7CiAgICAgICAgICAgIHN0cmluZyBzbyA9ICIiOwogICAgICAgICAgICBpbnQgaiA9IGk7CiAgICAgICAgICAgIHdoaWxlKGogPCBzLnNpemUoKSAmJiBpc051bWJlcihzW2pdKSkgewogICAgICAgICAgICAgICAgc28gKz0gc1tqXTsKICAgICAgICAgICAgICAgIGorKzsKICAgICAgICAgICAgfQogICAgICAgICAgICAKICAgICAgICAgICAgaW50IG51bSA9IDAsIHN6ID0gc28uc2l6ZSgpOwogICAgICAgICAgICBmb3IoaW50IGk9c3otMTsgaT49MDsgaS0tKQogICAgICAgICAgICAgICAgbnVtICs9IHBvdygxMCwgc3otaS0xKSooc29baV0tJzAnKTsKCiAgICAgICAgICAgIGlmKGt0c250KG51bSkpIGFucyA9IG1heChhbnMsIG51bSk7CiAgICAgICAgICAgIGkgPSBqLTE7CiAgICAgICAgfQogICAgfQogICAgY291dCA8PCBhbnMgPDwgJ1xuJzsKfQ==