#include <bits/stdc++.h>
int main() {
  unsigned long long n, k;
  unsigned long long res;
  scanf("%I64d%I64d", &n, &k);
  if (k > n >> 1) k = n >> 1;
  printf("%I64d", k * (2 * n - 2 * k - 1));
  return 0;
}
