#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  while (cin >> n >> m) {
    int q = m;
    for (int i = 1; i <= n && q != 0; i++) q /= 2;
    if (q == 0)
      cout << m << endl;
    else {
      int ans = m - (q * (1 << n));
      cout << ans << endl;
    }
  }
  return 0;
}
