#include <bits/stdc++.h>
using namespace std;
vector<vector<long long int>> g;
bool sortbysec(const pair<long long int, long long int> &a,
               const pair<long long int, long long int> &b) {
  if (a.first == b.first)
    return a.second < b.second;
  else
    return a.first < b.first;
}
long long int highest2(long long int n) {
  long long int x = n;
  while (n) {
    x = n;
    n = n & (n - 1);
  }
  return x;
}
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long int modInverse(long long int n, long long int p) {
  return power(n, p - 2, p);
}
long long int nCrModPFermat(long long int n, long long int r, long long int p) {
  if (r == 0) return 1;
  long long int fac[n + 1];
  fac[0] = 1;
  for (long long int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % p;
  return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) %
         p;
}
string findSum(string str1, string str2) {
  if (str1.length() > str2.length()) swap(str1, str2);
  string str = "";
  int n1 = str1.length(), n2 = str2.length();
  reverse(str1.begin(), str1.end());
  reverse(str2.begin(), str2.end());
  int carry = 0;
  for (int i = 0; i < n1; i++) {
    int sum = ((str1[i] - '0') + (str2[i] - '0') + carry);
    str.push_back(sum % 10 + '0');
    carry = sum / 10;
  }
  for (int i = n1; i < n2; i++) {
    int sum = ((str2[i] - '0') + carry);
    str.push_back(sum % 10 + '0');
    carry = sum / 10;
  }
  if (carry) str.push_back(carry + '0');
  reverse(str.begin(), str.end());
  return str;
}
long long int binomialCoeff(long long int n, long long int k) {
  long long int res = 1;
  if (k > n - k) k = n - k;
  for (long long int i = 0; i < k; ++i) {
    res *= (n - i);
    res /= (i + 1);
  }
  return res;
}
long long int factorial(long long int N) {
  long long int result = 1;
  while (N > 0) {
    result = result * N;
    N--;
  }
  return result;
}
void solve() {
  long long int c, d, m, k, q, j, b, p, y, i, x = 1, n, r;
  cin >> x >> y >> r >> c;
  r = r - x + 1;
  c = c - y + 1;
  if (r <= 1 || c <= 1)
    cout << 1 << endl;
  else
    cout << factorial(r + c - 2) / (factorial(r - 1) * factorial(c - 1))
         << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int x, q, y, m, t = 1, p3, vd, n, vp, row, k, col, i, j, p2, p1,
                            mno, R, l = 0, r = 0, count = 0, net1 = 2, net2 = 1;
  cin >> n >> k;
  if (k >= n / 2) k = n / 2;
  cout << 2 * k * n - (k * (k + 1)) - k * k;
  return 0;
}
