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