#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  long long mod = 1;
  int k = 0;
  while (k < n) {
    if (mod > m) {
      break;
    }
    mod *= 2;
    k++;
  }
  cout << m % mod << endl;
}
