#include <stdio.h>
unsigned char extractNibble(unsigned char reg, int pos) {
// Write your code here
if(pos == 1)
{
//extract upper nibble
reg >>= 4;
// make sure the upper is zero
reg &=0x0f;
}
else if( pos ==0)
{
reg &= 0x0f;
}
else{
printf("Invalid pos");
reg = 0;
}
return reg;
}
int main() {
unsigned char reg;
int pos;
scanf("%hhu %d", ®, &pos);
printf("%d", extractNibble(reg, pos));
return 0;
}