#include <bits/stdc++.h>
using namespace std;
template <class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& p) {
  return o << "(" << p.first << "," << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& vc) {
  o << "sz = " << vc.size() << endl << "[";
  for (const T& v : vc) o << v << ",";
  o << "]";
  return o;
}
long long N, D;
int main() {
  cin >> N >> D;
  long long a = N - D - 1;
  if (D == N - 1)
    cout << N - 1 << endl;
  else if (D == 1)
    cout << N * (N - 1) / 2 << endl;
  else
    cout << N - 1 + a * (a - 1) / 2 + 2 << endl;
}
