#include <bits/stdc++.h>
using namespace std;
long long a[int(1e5 + 5)], i, m, ans, k, l, j, q, x, n, ma, mi;
string s;
int main() {
  cin >> n >> k;
  ma = n * (n - 1) / 2;
  k = min(k, n / 2);
  for (i = 1; i <= k; i++) {
    ans += (n - 2 * i) * 2 + 1;
  }
  cout << ans << endl;
}
