#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back

using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

int main(){
	ll n=read(),d=read();
	if(d==1){
		cout<<n*(n-1)/2<<endl;
	}else{
		cout<<d+(n-d-1)*(n-d-2)/2+(n-d-1)*(3)<<endl;
	}
}