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