#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
const long long mod = 1e9 + 7;
int n, m;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  int nw = 0;
  int cst = 0;
  for (int i = (1); i <= (n); ++i) {
    if (nw < n - i) {
      int num = min(m - nw, n - i);
      cst += num * i;
      nw += num;
    }
    nw--;
  }
  cout << cst << '\n';
}
