#include <stdio.h>
#define UPPER_NIBBLE(reg) (((reg) >> 4) & 0xf)
#define LOWER_NIBBLE(reg) ((reg) & 0xf)
unsigned char extractNibble(unsigned char reg, int pos) {
return ((pos) ? UPPER_NIBBLE(reg) : LOWER_NIBBLE(reg));
}
int main() {
unsigned char reg;
int pos;
scanf("%hhu %d", ®, &pos);
printf("%d", extractNibble(reg, pos));
return 0;
}