#include <bits/stdc++.h>
using namespace std;
int main() {
  long double n, m;
  cin >> n >> m;
  long double log2_m = log(m) / log(2);
  if (log2_m < n) {
    cout << (unsigned long long)m << endl;
  } else if (log2_m == n) {
    cout << 0 << endl;
  } else {
    unsigned long long m_ = m;
    unsigned long long n_ = 1ULL << (unsigned long long)n;
    cout << m_ % n_ << endl;
  }
}
