#include <stdio.h>
#include <stdint.h>
uint8_t is_circular_match(uint16_t reg, uint16_t target) {
// Your code here
//uint8_t ret=0x00;
uint8_t count=0;
while(count<16)
{
if(reg==target)
return 1;
else
{
//int ret=reg>>15;
int ret=reg<<1|reg>>15;
reg=ret;
}
count+=1;
}
return 0;
}
int main() {
uint16_t reg, target;
scanf("%hu %hu", ®, &target);
printf("%hhu", is_circular_match(reg, target));
return 0;
}