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