#include<iostream.h>
 int l,l1,a,b,k;
 int prost();
 void proiz();

 int main()
  {
   int p;
   cin>>p;
   if(p<0 || p>1000){cout<<"Incorec input"; return 1;}
   cin>>k; if(k<0 || k>10){cout<<"Incorec input"; return 1;}
   l=p;
   if(p==1){if(k%2==0)cout<<'1'<<endl;
	      else cout<<'0'<<endl; return 0;}
   if(prost){if(k%2!=0)cout<<'1'<<endl;
	      else cout<<'0'<<endl; return 0;}
   cout<<"t";
   for(int i=0;i<k;i++)
    {proiz(); //cout<<l<<endl;
    }
  // cout<<l<<endl;
   return 0;
  }

 void proiz()
  {if(l==1){if(k%2==0)cout<<'1'<<endl;
	      else cout<<'0'<<endl; return;}
   if(prost){if(k%2!=0)cout<<'1'<<endl;
	      else cout<<'0'<<endl; return;}
     else l=a+b;

  }

 int prost()
  {
   int i=2,j,sum=0;
   while(i<=l/2)
    {if(l%i==0)sum+=l/i;
    i++; }
   if(sum>0){l=sum; return 0;}
    else return 1;
 /*  if(l%i==0){j=i;l=l/i;
    while(l%i!=0 && i<=l/2)
     i++;
    if(l%i==0){a=j; b=i;}
     else {a=j; b=0;}
    return 0;
     }
    else return 1; */
   }
