#include <bits/stdc++.h>
using namespace std;
double calc(int n) { return (n * n); }
int main() {
  int N, X;
  cin >> N >> X;
  double V = calc(N);
  double W = calc(X) + calc(N - X);
  int ans = N;
  while (true) {
    for (int i = (max(X, N - X) != N - 1) ? max(X, N - X) - 1 : 1; i > 0; i--) {
      if (fabs(V - W) >= calc(i)) {
        W += calc(i);
        ans += i;
      }
      if (fabs(V - W) == 0) break;
    }
    if (fabs(V - W) == 0) break;
  }
  cout << ans - 1 << endl;
  return 0;
}
