#include using namespace std; #define reep(i,a,b) for(int i=(a);i<(b);i++) #define rep(i,n) reep(i,0,(n)) typedef long long ll; __int128 bigIntMul(__int128 a, __int128 b, __int128 n){ __int128 ret=0; while(b){ if(b&1) ret=(ret+a)%n; a=(a+a)%n; b>>=1; } return ret; } __int128 bigIntMillerRabinSuspectPow(int a, __int128 k, __int128 n){ __int128 p=1; __int128 bit=0x80000000; for(bit=bit*bit*0x40000000;bit;bit>>=1){ if(p>1) p=bigIntMul(p,p,n); if(k&bit) p=bigIntMul(p,a,n); } return p; } int bigIntMillerRabinSuspect(int b, __int128 n){ __int128 i,t=0,u=n-1; __int128 now,next; while(!(u&1)) t++,u>>=1; now = bigIntMillerRabinSuspectPow(b, u, n); if(now==1) return 1; for(i=1;i<=t;i++){ next=bigIntMul(now,now,n); if(next==1 && now!=1 && now!=n-1) return 0; now=next; } return next==1; } int bigIntMillerRabin(__int128 n){ if(n<=1) return 0; if(n<=3) return 1; if(!(n&1)) return 0; if(!bigIntMillerRabinSuspect(2,n)) return 0; for(int i=3;i<=1201;i+=2) if(!bigIntMillerRabinSuspect(i,n)) return 0; return 1; } bool prime[100000]; int main(){ string s; cin>>s; __int128 n=0; rep(i,s.size()){ n*=10; n+=s[i]-'0'; } if(n<10000){ reep(i,2,100000) prime[i]=true; for(int i=2;i*i<=100000;i++){ if(prime[i]){ for(int j=i*i;j<100000;j+=i){ prime[j]=false; } } } ll m=n; reep(i,2,m){ queue q; q.push(1); vector used(m+1); used[1]=true; while(q.size()){ int top=q.front(); q.pop(); // top+1 top-1 top+i top-i int next = top+1; if(next<=m&&top%i!=0&&!prime[next]&&!used[next]) q.push(next),used[next]=true; next = top-1; if(0