#include <stdio.h>
#include <stdint.h>
unsigned char extractNibble(unsigned char reg, int pos){
unsigned char output;
// pos = 1 -> upper, pos = 0 -> lower
if(pos)
{
output = (reg >> 4) & 0x0F;
}
else
{
output = reg & 0x000F;
}
return output;
}
int main(){
unsigned char reg;
int pos;
scanf("%hhu %d", ®, &pos);
printf("%hhu", extractNibble(reg, pos));
}