#include <bits/stdc++.h>
using namespace std;
long long ans = 0;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, k;
  cin >> n >> k;
  int a[n + 3];
  for (int i = 1; i <= n; i++) a[i] = i;
  int temp = n / 2;
  temp = min(k, temp);
  for (int i = 1; i <= temp; i++) {
    ans += (n - i);
  }
  for (int i = temp + 1; i <= n; i++) {
    if ((n - i + 1) <= temp and temp > 0) temp--;
    ans += temp;
  }
  cout << ans;
}
