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