#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void output(T a, int p) {
  if (p)
    cout << fixed << setprecision(p) << a << "\n";
  else
    cout << a << "\n";
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  long long N, D;
  cin >> N >> D;
  if (D == 1) {
    cout << N * (N - 1) / 2 << endl;
  } else if (D == 2) {
    cout << N * (N - 1) / 2 - 1 << endl;
  } else {
    cout << D - 1 + (N - 2) * (N - 3) / 2 << endl;
  }
  return 0;
}
