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