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