#include <stdio.h>
unsigned char modifyBit(unsigned char reg, int pos, int mode) {
unsigned char temp = (0x01)<<pos;
if(mode==1){
return (reg|temp);
}
else{
temp=~(temp);
return (reg&temp);
}
}
int main() {
unsigned char reg;
int pos, mode;
scanf("%hhu %d %d", ®, &pos, &mode);
printf("%d", modifyBit(reg, pos, mode));
return 0;
}