#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, x;
  cin >> n >> x;
  if (n % 2 == 0) {
    cout << (n - x) * 3 << endl;
  } else {
    cout << (n - 1) * 3 << endl;
  }
  return 0;
}
