#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, ob, R = 0;
  cin >> n >> k;
  ob = min(n / 2, k);
  long long m = n - 1;
  for (int i = 0; i < ob; i++) {
    R += m;
    m--;
  }
  m = 0;
  for (int i = 0; i < ob; i++) {
    R += m;
    m++;
  }
  R += (n - (2 * ob)) * ob;
  cout << R;
  return 0;
}
