#include<bits/stdc++.h> using namespace std; int D, N; int main() { while (scanf("%d%d", &D, &N)!=EOF) { int k = 1; for (int i = 0; i < D - 1; i++) { if (N % 2) { k = k * 2; N = (N + 1) / 2; } else { k = k * 2 + 1; N /= 2; } } printf("%d ", k); } }