#include <bits/stdc++.h>
const int SZ = 1e5 + 5;
using namespace std;
long long C(long long x) {
  if (x < 1LL) return 0;
  return 1LL * x * (x + 1LL) / 2LL;
}
int main() {
  long long n, k;
  cin >> n >> k;
  k = min(k, n / 2LL);
  long long res = C(n - 1) - C(n - 1 - k) + C(k - 1) + (n - 2 * k) * k;
  cout << res;
}
