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