#include <iostream>
#include <math.h>
using namespace std;
int main ()
{
int n,being;
bool isprime=1;
while(cin>>n)
{
isprime=1;
if(n==0)
{
break;
}
else
{
if(n==1)
{
cout<<"1"<<endl;
}
else
{
for(int being=2;being*being<=n;being++)
{
if(n%being==0)
{
isprime=0;
break;
}
}
if(isprime==1)
{
cout<<"0"<<endl;
}
else
{
cout<<"1"<<endl;
}
}
}
}
}