#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  unsigned long long ans = 0;
  if (n == 1) {
    cout << ans << endl;
    return 0;
  }
  int m = n >> 1;
  bool all = false;
  if (k >= m) {
    for (int i = 0, j = n - 1; i < n; i++, j--) {
      ans += j;
    }
    cout << ans << endl;
    return 0;
  }
  for (int i = 0, j = n - 1; i < k; i++, j--) {
    ans += j;
  }
  ans += k * (n - (2 * k));
  for (int i = 0, j = k - 1; i < k; i++, j--) {
    ans += j;
  }
  cout << ans << endl;
  return 0;
}
