#include <stdio.h>
unsigned char modify_bit(unsigned char bit, int pos, int mode){
// mode: 0-clear, 1-set
if(mode == 0){
bit = bit & ~(1 << pos);
}
else{
bit = bit | (1 << pos);
}
return bit;
}
int main(){
unsigned char bit;
int pos,mode ;
scanf("%hhu %d %d",&bit,&pos,&mode);
printf("%hhu",modify_bit(bit,pos,mode));
return 0;
}