#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000000ll;
const long long MOD = 1000000007ll;
const double EPS = 1e-8;
int main(void) {
  int n;
  int x;
  cin >> n >> x;
  long long ans = 0;
  if (n % 2 == 1) {
    ans = (n - 1) * 3;
  } else {
    ans = (n / 2) * 3 + abs((x - n / 2)) * 3;
  }
  cout << ans << endl;
  return 0;
}
