#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, c, a;
  cin >> n >> k;
  c = max(n - 2 * k, 0LL);
  a = n * (n - 1) / 2 - c * (c - 1) / 2;
  cout << a << endl;
  return 0;
}
