#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d;
  cin >> n >> d;
  int m = n - d - 1;
  if (d == 1)
    cout << n * (n - 1) / 2 << endl;
  else if (d == 2)
    cout << n * (n - 1) / 2 - 1 << endl;
  else
    cout << d + m * (m - 1) / 2 + 2 * m << endl;
  return 0;
}
