#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  if (k > n / 2) {
    k = n / 2;
  }
  cout << k * n - k * (k + 1) / 2 + k * (n - 2 * k) + k * (k - 1) / 2;
}
