#include <bits/stdc++.h>
using namespace std;
int main() {
  istream &input = cin;
  ostream &output = cout;
  long long N = 0, K = 0;
  input >> N >> K;
  if (K > N / 2) K = N / 2;
  long long result = 0;
  if (K > 0) {
    result = ((N - 1) + (N - 2 * K)) * K;
  }
  output << result << endl;
  return 0;
}
