#include <bits/stdc++.h>
using namespace std;
long long rdtsc() {
  long long tmp;
  asm("rdtsc" : "=A"(tmp));
  return tmp;
}
inline int myrand() { return abs((rand() << 15) ^ rand()); }
inline int rnd(int x) { return myrand() % x; }
const int INF = (int)1.01e9;
const long double EPS = 1e-9;
const long double PI = acos(-1.0L);
void precalc() {}
int n, k;
bool read() {
  if (scanf("%d%d", &n, &k) < 2) {
    return 0;
  }
  return 1;
}
void solve() {
  long long res = 0;
  for (int i = 0; i < k; ++i) {
    int j = n - 1 - i;
    if (j <= i) {
      break;
    }
    res += (j - i) * 2 - 1;
  }
  printf(
      "%lld"
      "\n",
      res);
}
int main() {
  srand(rdtsc());
  precalc();
  while (1) {
    if (!read()) {
      break;
    }
    solve();
  }
  return 0;
}
