#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  if (k >= n / 2) {
    printf("%lld\n", 1LL * n * (n - 1) / 2);
    return 0;
  }
  printf("%lld\n", 1LL * k * (2 * n - 2 * k - 1));
  return 0;
}
