#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int i, j, n, x;
  double sum, x2;
  cin >> n >> x;
  sum = 0;
  sum += (n - x);
  sum += x;
  x2 = (double)x / 2;
  sum += (double)x2 * 3;
  sum += (double)((n - x) - x2) * 2;
  cout << sum << endl;
}
