#include <stdio.h>
int fun(int reg, int pos, int mode)
{
if (mode == 1) {
reg = reg | (1 << pos);
} else {
reg = reg & ~(1 << pos);
}
return reg;
}
int main() {
int reg_val, bit_pos, mode;
scanf("%d %d %d", ®_val, &bit_pos, &mode);
int output = fun(reg_val, bit_pos, mode);
printf("%d", output);
return 0;
}