#include <bits/stdc++.h>
using namespace std;
template <typename T>
T sqr(T x) {
  return x * x;
}
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
const int MAXN = (int)1e5 + 10;
int n, k, a[MAXN];
long long cnt = 0;
int m;
int main() {
  ios_base ::sync_with_stdio(false);
  cin >> n >> k;
  m = n;
  for (int i = 1; i <= n; i++) a[i] = i;
  for (int i = 1; i <= min(n / 2, k); i++) {
    cnt += m * 2 - 3;
    m -= 2;
  }
  cout << cnt;
}
