#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
int n, k;
long long fac[100005];
void init() {
  fac[0] = 0;
  for (int i = 0; i < 100005; i++) {
    fac[i] = fac[i - 1] + i;
  }
}
int main() {
  ios::sync_with_stdio(false);
  init();
  while (cin >> n >> k) {
    if (k >= n / 2) {
      cout << fac[n - 1] << "\n";
    } else {
      cout << fac[n - 1] - fac[n - 1 - k] +
                  (long long)(n - k * 2) * (long long)k + fac[k - 1];
    }
  }
  return 0;
}
