#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  if (n % 2 == 0) {
    long long t = abs(n / 2 - m);
    long long mid = n * 3 / 2;
    cout << mid + 3 * t << endl;
  } else {
    cout << (3 * (n - 1)) << endl;
  }
  return 0;
}
