#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long a, b;
  cin >> a >> b;
  if (a == 1) {
    cout << "0\n";
    return 0;
  }
  if (2 * b < a) {
    cout << (2 * a * b - 2 * b * b - b) << endl;
    return 0;
  }
  cout << ((a - 1) * a) / 2 << endl;
  return 0;
}
