#include <stdio.h>
unsigned char extractNibble(unsigned char reg, int pos) {
// since pos refers to nibble position and not bit position
// we either shift left 0 (for the lower nibble) or 4 (for the upper nibble).
unsigned char result = (reg >> (pos == 0 ? 0 : 4)) & 0x0F;
return result;
}
int main() {
unsigned char reg;
int pos;
scanf("%hhu %d", ®, &pos);
printf("%d", extractNibble(reg, pos));
return 0;
}