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