#include <bits/stdc++.h>
using namespace std;
const int INT_MX = (1 << 31) - 1;
const int INT_MN = (1 << 31);
template <typename ret, typename var>
ret bpow(var a, var n) {
  ret res = 1;
  while (n) {
    if (n & 1) {
      res *= a;
    }
    a *= a;
    n >>= 1;
  }
  return res;
}
void solve() {
  long long n, m;
  cin >> n >> m;
  long long exp = 1, p = 0;
  while ((exp << 1) <= m) {
    exp <<= 1;
    ++p;
  }
  if (p < n) {
    cout << m;
  } else {
    cout << m % bpow<long long, long long>(2, n);
  }
}
int main() {
  solve();
  return 0;
}
