/*  -*- coding: utf-8 -*-
 *
 * 1591.cc: Graph Making
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

int main() {
  int n, d;
  scanf("%d%d", &n, &d);

  ll sum = d - 1;
  sum += (ll)(n - d + 1) * (n - d) / 2;
  if (d > 1) sum += n - d - 1;

  printf("%lld\n", sum);
  return 0;
}

