#include <stdio.h>
unsigned char extractNibble(unsigned char reg, int pos) {
// Use a nibble mask 4 lower bits and shift it if required by using the pos argument (it can be used as a flag).
reg &= (0x0F << (4*pos));
// After the value is masked shift it to the lowest significant position using again the pos argument as a flag.
return (reg >> (4*pos));
}
int main() {
unsigned char reg;
int pos;
scanf("%hhu %d", ®, &pos);
printf("%d", extractNibble(reg, pos));
return 0;
}