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