#include<bits/stdc++.h>
using namespace std;
int p[65540]={1,1};
vector<int>v;
void miku(int n){
for(int i=2;i<n;++i){
if(p[i]==0)v.push_back(i);
for(int j:v){
if(i*j>n)break;
p[i*j]=1;
if(i%j==0)break;
}
}
}
int main() {ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
miku(65539);
int n;
while(cin>>n,n){
if(n<65540){
if(p[n]==0)cout<<"0\n";
else cout<<"1\n";
}
else {
int f=0;
for(int j:v)if(n%j==0){f=1;break;}
if(f)cout<<"1\n";
else cout<<"0\n";
}
}
}