#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, c, z, p;
  scanf("%lld%lld", &n, &k);
  c = (n - 1) / 2 - k;
  p = (n - 1) / 2;
  if (c < 0) {
    c = 0;
    k = n / 2;
  }
  if (n % 2 == 0) {
    z = (p * (p + 1) - c * (c + 1)) * 2 + k;
  } else {
    z = (p * p - c * c) * 2 + k;
  }
  printf("%lld\n", z);
}
