#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
int main() {
  long long n, m;
  cin >> n >> m;
  long long now = 2;
  int i;
  for (i = 1; i < n; i++) {
    now *= 2;
    if (now > m) break;
  }
  if (i < n)
    cout << m << endl;
  else
    cout << m % now << endl;
  return 0;
}
