#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<long double, long double> pdd;
typedef vector<vector<ll> > matrix;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define popb pop_back
#define pf push_front
#define popf pop_front
template <class T> inline T sqr(T x) { return x * x; };
template <class T> inline bool maximize(T& a, T b) { return (a < b) ? a = b, true : false; }
template <class T> inline bool minimize(T& a, T b) { return (a > b) ? a = b, true : false; }
string lowcase = "abcdefghijklmnopqrstuvwxyz";
string upcase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string number = "0123456789";
int dx[] = {0, 0, -1, 1};
int dy[] = {-1, 1, 0, 0};
const ll pd = 1e9 + 7;
const ll oo = 9e18 + 1;
const int MX = 200100, LIM = 1e6;
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';
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKIAp0eXBlZGVmIGxvbmcgbG9uZyBsbDsKdHlwZWRlZiBsb25nIGRvdWJsZSBsZDsKdHlwZWRlZiBwYWlyPGxsLCBsbD4gcGxsOwp0eXBlZGVmIHBhaXI8aW50LCBpbnQ+IHBpaTsKdHlwZWRlZiBwYWlyPGxvbmcgZG91YmxlLCBsb25nIGRvdWJsZT4gcGRkOwp0eXBlZGVmIHZlY3Rvcjx2ZWN0b3I8bGw+ID4g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ICByZXR1cm4gdHJ1ZTsKfQpib29sIGlzTnVtYmVyKGNoYXIgY2gpIHsKICAgIHJldHVybiAoY2ggPj0gJzAnICYmIGNoIDw9ICc5Jyk7Cn0KaW50IG1haW4gKCl7CiAgICBzdHJpbmcgczsgY2luID4+IHM7CiAgICBpbnQgYW5zID0gMDsKICAgIGZvcihpbnQgaT0wOyBpPHMuc2l6ZSgpOyBpKyspIHsKICAgICAgICBpZihpc051bWJlcihzW2ldKSkgewogICAgICAgICAgICBzdHJpbmcgc28gPSAiIjsKICAgICAgICAgICAgaW50IGogPSBpOwogICAgICAgICAgICB3aGlsZShqIDwgcy5zaXplKCkgJiYgaXNOdW1iZXIoc1tqXSkpIHsKICAgICAgICAgICAgICAgIHNvICs9IHNbal07CiAgICAgICAgICAgICAgICBqKys7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgCiAgICAgICAgICAgIGludCBudW0gPSAwLCBzeiA9IHNvLnNpemUoKTsKICAgICAgICAgICAgZm9yKGludCBpPXN6LTE7IGk+PTA7IGktLSkKICAgICAgICAgICAgICAgIG51bSArPSBwb3coMTAsIHN6LWktMSkqKHNvW2ldLScwJyk7CgogICAgICAgICAgICBpZihrdHNudChudW0pKSBhbnMgPSBtYXgoYW5zLCBudW0pOwogICAgICAgICAgICBpID0gai0xOwogICAgICAgIH0KICAgIH0KICAgIGNvdXQgPDwgYW5zIDw8ICdcbic7Cn0=