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