#include <bits/stdc++.h>
using namespace std;
long double pi = 3.1415926536;
int main() {
  long long n, k;
  cin >> n >> k;
  long long res = 0, ind = 1;
  while (ind < n && k > 0) {
    res += (n - ind + n - ind + 1 - 2);
    ind++;
    k--;
    n--;
  }
  cout << res;
}
