#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  if (n == 1) {
    cout << m % 2 << endl;
  } else if (n >= 27)
    cout << m << endl;
  else {
    int k = int(pow(2, n));
    cout << m % k << endl;
  }
  return 0;
}
