#include <stdio.h>
unsigned char extractNibble(unsigned char reg, int pos) {
// Write your code here
int res = 0;
for (int i=0; i<4; i++ )
{
if (pos == 0)
{
res = res | (reg & (1 << i));
}
if (pos == 1)
{
res = res | (reg & (1 << (i+4)))>>4;
}
}
return res;
}
int main() {
unsigned char reg;
int pos;
scanf("%hhu %d", ®, &pos);
printf("%d", extractNibble(reg, pos));
return 0;
}