#include <stdio.h>
#include <cstdint>
unsigned char modifyBit(unsigned char reg, int pos, int mode) {
// Write your code here
uint8_t i=1<<pos;
return mode?(reg|i):(reg&(~i));
}
int main() {
unsigned char reg;
int pos, mode;
scanf("%hhu %d %d", ®, &pos, &mode);
printf("%d", modifyBit(reg, pos, mode));
return 0;
}