#include <stdio.h>
#include <stdint.h>
int check(uint16_t reg,uint16_t target, uint8_t n) {
uint8_t i = 0;
for (i = 0; i < 16; i++) {
uint16_t match = (reg << i) | (reg >> (16 - i));
if (match == target) {
return 1;
}
}
return 0;
}
int main() {
uint16_t reg,target, n;
scanf("%hu%hu", ®,&target, &n);
printf("%d",check(reg, target, n));
}