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