#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int main() {
  int n, x;
  cin >> n >> x;
  int result = 0;
  if (n < 2 * x) {
    result = x + (n - x) * (x + 1);
  } else if (n > 2 * x) {
    result = n + 2 * x + (n - 2 * x) * (x + 1);
  } else if (n = 2 * x) {
    result = 3 * x;
  }
  cout << result << endl;
}
