#include <bits/stdc++.h>
using namespace std;
const int INF = 999999999;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long int n, x;
  cin >> n >> x;
  if (n % 2)
    cout << (n - 1) * 3 << endl;
  else
    cout << (n - (n - (x % 2))) * 3 << endl;
}
