#include <bits/stdc++.h>
using namespace std;

long long a;
long long u, x, y, z;

long long int delta(long long a, long long b)
  { a = a^b; return(a); }

long long int accept(long long a)
  { if ((a==3) || (a==5) || (a==6)) { return 1; } else { return 0; } }

int main() {   long long int x, y, a, b;
               printf("This program checks whether a number\nin octal digits");
               printf(" satisfies that the bit-wise\neor of the digits is in ");
               printf("{3,5,6}.\n");
 
        line1: printf("Provide the input x greater equal 0: ");
               scanf("%lld", &x); if (x<0) { goto line1; }
	       printf("Input x provided is %lld and octal value is ",x);
               y = 1; a = 0; x = x+x; x = x+x; x=x+x; x=x+1;
		
	line2: if (y > x) { goto line3; } 
               else { y=y+y; y=y+y; y=y+y; goto line2; }
	
	line3: x = x+x; x = x+x; x = x+x;
               if (x != y) { b=0;
                  if (x >= y) { x=x-y; b++; }
                  if (x >= y) { x=x-y; b++; }
                  if (x >= y) { x=x-y; b++; }
                  if (x >= y) { x=x-y; b++; }
                  if (x >= y) { x=x-y; b++; }
                  if (x >= y) { x=x-y; b++; }
                  if (x >= y) { x=x-y; b++; }
                  putchar(b+48);
                  a = delta(a,b); goto line3; }

	line4: printf(".\nState is %lld and acc/rej is %lld.\n",a,accept(a)); }
		
