#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define ALL(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef LL ut;
typedef pair<ut,ut> pr;
typedef vector<ut> VI;
typedef vector<pr> Vpr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
const int SIZE=3*1e5;
const ut INF=1LL<<60;
int main(){
	LL n,d;
	cin >> n >> d;
	LL clerk=n-d;
	LL getter=min(d,2LL);
	LL ans=clerk*(clerk-1)/2+clerk*getter+(d-getter);
	cout << ans << endl;
	return 0;
}