#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, kol_par;
  cin >> n >> kol_par;
  long long sum = 0;
  for (int i = 1; i < n; i++) {
    if (i <= kol_par)
      sum += (n - i);
    else if (i < n - kol_par)
      sum += kol_par;
    else
      sum += (n - i);
  }
  cout << sum << endl;
  return 0;
}
