#include <bits/stdc++.h>
using namespace std;
int MOD = 1e9 + 7;
long long INF = 1e18;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int main() {
  long long n, x;
  cin >> n >> x;
  if (n % 2 == 1) {
    cout << (n - 1) * 3LL << endl;
  } else {
    cout << abs(n / 2LL - x) * 3LL + n / 2LL * 3LL << endl;
  }
}
