#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	ll N,D;
	scanf("%lld %lld",&N,&D);

	if(D == 1){
		printf("%lld\n",(N*(N-1))/2);
	}else if(D == N-1){
		printf("%lld\n",D);
	}else{
		printf("%lld\n",(N-1)+((N-D)*(N-D-1))/2+(N-D-1));
	}

	return 0;
}