#include <bits/stdc++.h>
#define rep(i,n)for(unsigned long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main() {
  unsigned n, x;
  cin >> n >> x;
  unsigned ans;
  if(n%2==1){
    n/=2;
    ans = n*6;
  }
  else{
    ans = 3*n/2;
    unsigned gap = abs(n/2-x);
    ans += gap*3;
  }
  cout << ans << endl;
}