#include <stdio.h>
#include <stdint.h>
uint8_t is_circular_match(uint16_t reg, uint16_t target) {
// Your code here
int count = 1;
uint16_t pp;
int found = 0;
while(reg)
{
// pp = reg & target;
if(reg == target)
{
found++;
break;
}
reg = ((reg << count) | (reg >> (16- count)));
// printf("\n %d", reg);
count++;
}
// printf("%d", found);
return found;
}
int main() {
uint16_t reg, target;
scanf("%hu %hu", ®, &target);
printf("%hhu", is_circular_match(reg, target));
return 0;
}