#include <bits/stdc++.h>
using namespace std;
int MOD = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  ;
  long long t = 1;
  while (t--) {
    long long n, m;
    cin >> n;
    cin >> m;
    long long base = 1, now = 0;
    for (int i = 1; i <= n; i++) {
      base = base * 2;
      if (base > m) {
        now = i;
        break;
      }
    }
    if (!now) {
      cout << m % base;
    } else {
      cout << m;
    }
  }
  return 0;
}
