#include <bits/stdc++.h>
using namespace std;
long long Sum(long long n) { return n * (n + 1) / 2; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, k;
  cin >> n >> k;
  long long value1 = n / 2;
  long long answer = 0;
  if (value1 <= k) {
    cout << Sum(n - 1) << endl;
  } else {
    for (int i = 1; i <= k; i++) {
      answer += 2 * (n - 2 * i) + 1;
    }
    cout << answer << endl;
  }
  return 0;
}
