//d+1????????§???????????????
//??????n-d-1????????§?????¨??°???????????????
//????????????min(3, d+1)??????????????¨??°???????????????(n-d-1??????)??¨????????????
//????????\??????????????£??????, ????????§????¨????????????????
//d + (n - d - 1) * (n - d - 2) / 2 + (n - d - 1) * min(3, d + 1)

#include <iostream>
#include <algorithm>
using namespace std;

long long n, d;

int main() {
	cin >> n >> d;
	cout << d + (n - d - 1) * (n - d - 2) / 2 + (n - d - 1) * min(3LL, d + 1) << endl;
	return 0;
}