#include <bits/stdc++.h>
using namespace std;
long long p = 1000000000 + 7;
int main() {
  long long n, k;
  cin >> n >> k;
  if (k > (n + 1) / 2) {
    cout << (n * (n - 1)) / 2;
    return 0;
  }
  long long tot = 0;
  for (long long i = 0; i < k; i++) {
    if (2 * n - 3 > 0)
      tot += 2 * n - 3;
    else
      break;
    n -= 2;
  }
  cout << tot << endl;
}
