#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
int read() {
  int i;
  scanf("%d", &i);
  return i;
}
int main() {
  ll n = read(), d = read();
  if (d == 1) {
    cout << n * (n - 1) / 2 << endl;
  } else {
    cout << d + (n - d - 1) * (n - d - 2) / 2 + (n - d - 1) * (d + 1) << endl;
  }
}
