#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, x;
  cin >> n >> x;
  if (x == (2 * n)) {
    cout << (3 * x) << endl;
  } else if (x > (n / 2)) {
    x = n - x;
    float ans = (((7 * x) / 2) + n);
    cout << ans << endl;
  } else {
    float ans = (((7 * x) / 2) + n);
    cout << ans << endl;
  }
  return 0;
}
