#include <bits/stdc++.h>
using namespace std;
long long m, n;
signed main() {
  cin >> n >> m;
  long long cur = 1, step = 0;
  if (n == 0) {
    cout << 0;
    return 0;
  }
  while (cur <= m && step < n) {
    cur *= 2;
    step++;
  }
  if (step == n) {
    cout << m % cur;
  } else {
    cout << m;
  }
}
