#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int i, j, n, x, sum;
  cin >> n >> x;
  sum = 0;
  sum += x;
  sum += n - x;
  sum += x * 2;
  sum += (n - x * 2) * 3;
  cout << sum << endl;
  exit(0);
}
