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