#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define int long long int
using namespace std;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef vector<PII> VP;

int n, d;

signed main()
{
  cin >> n >> d;

  if(d == 1){
    cout << 1 + 2 * (n - 2) + (n - 2) * (n - 3) / 2 << endl;
  }
  else{
    cout << d + 3 * (n - d - 1) + (n - d - 1) * (n - d - 2) / 2 << endl;
  }
  return 0;
}