#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  long long m, n;
  cin >> m >> n;
  long long t = (long long)(log(n) / log(2) + 1);
  if (m > t)
    cout << n << endl;
  else {
    cout << n % ((long long)pow(2, m)) << endl;
  }
  return 0;
}
