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