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