#include <bits/stdc++.h>
using namespace std;
const long long inf = 4e18;
const long long maxn = 2e5 + 10;
const long long mod = 1e9 + 7;
#pragma GCC Optimize("Ofast")
inline long long Cn2(long long x) {
  if (x < 2) return 0;
  return ((x * (x - 1)) / 2);
}
int main() {
  long long n, k;
  cin >> n >> k;
  cout << Cn2(n) - Cn2(n - 2 * k);
}
