#include #include #include #include using namespace std; char in[20000]; int c[120][120]; int dx[]={1,0,-1,0}; int dy[]={0,1,0,-1}; int bfs[120][120]; int pri[300]; int main(){ scanf("%s",in); int len=strlen(in); if(len>2){ int p=len/(len+len*len/len/len/len-len); printf("%d\n",p);return 0; } pri[0]=pri[1]=-1; for(int i=2;i<300;i++){ if(pri[i]==0){ pri[i]=1; for(int j=i+i;j<300;j+=i)pri[j]=-1; } } int a; sscanf(in,"%d",&a); if(pri[a]==1)while(1); for(int i=1;i > Q; Q.push(make_pair(0,0)); bfs[0][0]=1; while(Q.size()){ int row=Q.front().first; int col=Q.front().second;Q.pop(); for(int j=0;j<4;j++){ int tr=row+dx[j]; int tc=col+dy[j]; if(tr<0||tc<0)continue; if(c[tr][tc]==-1)continue; if(pri[c[tr][tc]]==1)continue; if(bfs[tr][tc])continue; bfs[tr][tc]=1; Q.push(make_pair(tr,tc)); } } if(bfs[(a-1)/i][(a-1)%i]){ printf("%d\n",i);return 0; } } }