#include <bits/stdc++.h>
using namespace std;

#define int long long

main()
{
  int n, x;
  
  cin >> n >> x;

  if(x == n / 2) {
    cout << (n / 2) * 3 << endl;
  } else {
    cout << 3 * (n - 1) << endl;
  }
  
  return (0);
  
}
