#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  long long pa = min(n / 2, k);
  long long res1 = (n - 2 * pa) * pa;
  long long res2 = (pa - 1) * pa / 2 + (2 * n - 1 - pa) * pa / 2;
  cout << res1 + res2 << endl;
  return 0;
}
