#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  long long temp = log2(m);
  if (n > temp)
    cout << m << endl;
  else {
    long long p = pow(2, n);
    cout << m % p << endl;
  }
}
