#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll n,d;

int main(void){
	scanf("%lld%lld",&n,&d);
	if(d==1){
		printf("%lld\n",n*(n-1)/2LL);
		return 0;
	}
	if(d==n-1){
		printf("%lld\n",n-1LL);
		return 0;
	}
	ll res=(n-d+1)*(n-d)/2LL;
	res--;
	res+=n-1LL;
	printf("%lld\n",res);
	return 0;
}