#include <bits/stdc++.h>
using namespace std;
int get() {
  char ch;
  while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-')
    ;
  if (ch == '-') {
    int s = 0;
    while (ch = getchar(), ch >= '0' && ch <= '9') s = s * 10 + ch - '0';
    return -s;
  }
  int s = ch - '0';
  while (ch = getchar(), ch >= '0' && ch <= '9') s = s * 10 + ch - '0';
  return s;
}
int main() {
  int n = get();
  int m = get();
  long long v = 1, ans;
  bool bz = 0;
  for (int i = 1; i <= n; i++) {
    v = v * 2;
    if (m < v) {
      bz = 1;
      break;
    }
  }
  if (bz)
    printf("%d\n", m);
  else
    cout << m % v << endl;
  return 0;
}
