#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 8;
const int logN = 20, BL = 400;
const double EPS = 3e-16;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  long long n, x;
  cin >> n >> x;
  long long ans = 0, d = 1;
  while (x > 0) {
    ans += d * (3 * x);
    d <<= 1;
    x /= 2;
  }
  cout << ans;
  return 0;
}
