#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  long long ans = 0;
  for (int i = 0; i < min(n / 2, k); ++i) {
    ans += 2LL * (n - 1LL - 2LL * i) - 1;
  }
  cout << ans << endl;
  return 0;
}
