#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define M 1000000000
ll pro(ll a,ll b,ll n)
{
if(a<M && b<M)
return (a*b)%n;
if(b==0 || a==0)
return 0;
if(b==1)
return a%n;
else if(b%2==0)
return pro((a+a)%n,b/2,n);
else if(b%2==1)
return (a+pro((a+a)%n,b/2,n))%n;
}
ll bit(ll p,ll q,ll mod)
{
ll r=1;
while(q>0)
{
if(q&1)
r=pro(r,p,mod);
q=q>>1,p=pro(p,p,mod);
}
return r;
}
int test(ll n,ll d,int r)
{
ll y,a=rand()%(n-4)+2;
y=bit(a,d,n);
if(y==1 || y==n-1)
return 1;
while(r>1)
{
y=pro(y,y,n),r--;
if(y==1)
return 0;
else if(y==n-1)
return 1;
}
return 0;
}
int mill(ll n,int k)
{
if(n==1)return 0;
else if(n<=3)return 1;
else if(n%2==0)return 0;
else
{
int i,r=0;
ll d=n-1;
while(d%2==0)d/=2,r++;
for(i=0;i<k;i++)
{
if(test(n,d,r)==0)
return 0;
}
return 1;
}
}
int main()
{
ll n;
cin >> n;
int x=mill(n,4);
cout << x << endl;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKdHlwZWRlZiBsb25nIGxvbmcgaW50IGxsOwojZGVmaW5lIE0gMTAwMDAwMDAwMApsbCBwcm8obGwgYSxsbCBiLGxsIG4pCnsKICAgIGlmKGE8TSAmJiBiPE0pCiAgICAgICAgcmV0dXJuIChhKmIpJW47CiAgICBpZihiPT0wIHx8IGE9PTApCiAgICAgICAgcmV0dXJuIDA7CiAgICBpZihiPT0xKQogICAgICAgIHJldHVybiBhJW47CiAgICBlbHNlIGlmKGIlMj09MCkKICAgICAgICByZXR1cm4gcHJvKChhK2EpJW4sYi8yLG4pOwogICAgZWxzZSBpZihiJTI9PTEpCiAgICAgICAgcmV0dXJuIChhK3BybygoYSthKSVuLGIvMixuKSklbjsKfQpsbCBiaXQobGwgcCxsbCBxLGxsIG1vZCkKewogICAgbGwgcj0xOwogICAgd2hpbGUocT4wKQogICAgewogICAgICAgIGlmKHEmMSkKICAgICAgICAgICAgcj1wcm8ocixwLG1vZCk7CiAgICAgICAgcT1xPj4xLHA9cHJvKHAscCxtb2QpOwogICAgfQogICAgcmV0dXJuIHI7Cn0KaW50IHRlc3QobGwgbixsbCBkLGludCByKQp7CiAgICBsbCB5LGE9cmFuZCgpJShuLTQpKzI7CiAgICB5PWJpdChhLGQsbik7CiAgICBpZih5PT0xIHx8IHk9PW4tMSkKICAgICAgICByZXR1cm4gMTsKICAgIHdoaWxlKHI+MSkKICAgIHsKICAgICAgICB5PXBybyh5LHksbiksci0tOwogICAgICAgIGlmKHk9PTEpCiAgICAgICAgICAgIHJldHVybiAwOwogICAgICAgIGVsc2UgaWYoeT09bi0xKQogICAgICAgICAgICByZXR1cm4gMTsKICAgIH0KICAgIHJldHVybiAwOwp9CmludCBtaWxsKGxsIG4saW50IGspCnsKICAgIGlmKG49PTEpcmV0dXJuIDA7CiAgICBlbHNlIGlmKG48PTMpcmV0dXJuIDE7CiAgICBlbHNlIGlmKG4lMj09MClyZXR1cm4gMDsKICAgIGVsc2UKICAgIHsKICAgICAgICBpbnQgaSxyPTA7CiAgICAgICAgbGwgZD1uLTE7CiAgICAgICAgd2hpbGUoZCUyPT0wKWQvPTIscisrOwogICAgICAgIGZvcihpPTA7aTxrO2krKykKICAgICAgICB7CiAgICAgICAgICAgIGlmKHRlc3QobixkLHIpPT0wKQogICAgICAgICAgICAgICAgcmV0dXJuIDA7CiAgICAgICAgfQogICAgICAgIHJldHVybiAxOwogICAgfQp9CmludCBtYWluKCkKewogICAgbGwgbjsKICAgIGNpbiA+PiBuOwogICAgaW50IHg9bWlsbChuLDQpOwogICAgY291dCA8PCB4IDw8IGVuZGw7Cn0K