#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:536870912")
const int MOD = 1000000007;
const int INF = 1000000001;
const int MAXN = 17;
const long double EPS = 1e-6;
const int HASH_POW = 29;
const long double PI = acos(-1.0);
using namespace std;
void my_return(int code) { exit(code); }
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  mt19937 mt_rand(time(0));
  int n, k;
  scanf("%d %d", &n, &k);
  if (k >= n / 2)
    printf("%I64d\n", n * 1ll * (n - 1) / 2);
  else {
    long long ans = 0;
    int ptr = n - 1;
    for (int i = 0; i < k; ++i) {
      ans += 2 * ptr - 1;
      ptr -= 2;
    }
    printf("%I64d\n", ans);
  }
  my_return(0);
}
