#include <bits/stdc++.h>
using namespace std;
long long t[46];
int main() {
  long long s = 1;
  long long n, m;
  for (int i = 0; i < 34; i++) {
    t[i] = s;
    s *= 2;
  }
  cin >> n >> m;
  if (n >= 34) {
    cout << m << endl;
  } else
    cout << m % t[n] << endl;
  return 0;
}
