#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long LINF = 1LL << 62;
const int INF = 10000;
int main() {
  long long N, x;
  cin >> N >> x;
  cout << 3 * N - (x + 1) << endl;
  return 0;
}
