#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
const int inf = 0x3f3f3f3f, N = 2e5 + 10;
const double pi = acos(-1);
using namespace std;
int main() {
  int n, k;
  while (cin >> n >> k) {
    long long ans = 0;
    int x = min(n / 2, k);
    ans += 1LL * x * (n - 1);
    if (x <= n / 2) ans += 1LL * (n - x * 2) * x;
    cout << ans << endl;
  }
  return 0;
}
