#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int x = n - 1;
  int sum = 0;
  for (int i = 1; i <= n - 1; i++) {
    if (m < x && i == 1) {
      sum += m * i;
      x -= m;
    } else if (x <= m && i == 1) {
      sum += x * i;
      break;
    } else if (i > 1 && x > 0) {
      sum += i;
      x--;
    } else
      break;
  }
  cout << sum;
}
