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