#include <bits/stdc++.h>
using namespace std;
long long n, x;
int main() {
  scanf("%lld%lld", &n, &x);
  if ((x % 2 == 1) || ((n - x) % 2 == 1))
    printf("%lld", (n - 1) * 3);
  else
    printf("%lld", n / 2 * 3);
}
