#include <stdio.h>
#include <stdint.h>
uint16_t rotate_right(uint16_t reg) {
if (reg & 1)
return ((reg >> 1) | 0x8000);
else
return (reg >> 1);
}
uint8_t is_circular_match(uint16_t reg, uint16_t target) {
// Your code here
uint16_t i, match=0;
for (i=0; (i < 16) && (!match); i++) {
reg= rotate_right(reg);
if ((reg ^ target) == 0)
match = 1;
}
return match;
}
int main() {
uint16_t reg, target;
scanf("%hu %hu", ®, &target);
printf("%hhu", is_circular_match(reg, target));
return 0;
}