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