#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m;
  cin >> n >> m;
  int twos = 0, rem = 0, i = 1;
  while (twos <= m and n) {
    twos = pow(2, i);
    ++i;
    n--;
  }
  cout << m % twos;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  t = 1;
  while (t--) solve();
  return 0;
}
