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