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