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

int main() {
	long long int n, k;
	cin >> n >> k;
	long long int ab = 2 * n;
	long long int res = 0;
	while (ab >= 2) {
		int cd = ab - k;
		if (cd >= 2 && cd <= 2 * n) {
			res += (n - abs(n + 1 - ab)) * (n - abs(n + 1 - cd));
		}
		ab--;
	}
	cout << res << endl;
	return 0;
}
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <set>
using namespace std;
typedef pair<int, int> pairII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long LL;
#define shig_for(i, a, b) for(int i = (a); i < (b); ++i)
#define shig_rep(i, n) shig_for(i, 0, n)
#define shig_forB(bit,a,b) for(int bit = (a); bit < (1<<(b)); ++bit)
#define shig_repB(bit,n) shig_forB(bit,0,n)
#define tmp int temp = 0
#define str string s

int main(){

    LL N, K, ans = 0;
    const LL zero = 0;
    cin >> N >> K;

    for(LL i = 2; i <= 2 * N; i++){

        if(i - K >= 2){
            //ans += (i - 1);
            //ans += (i - K - 1);
            LL tempA = -1 * (((i - N) - 1) * 2);
            LL tempB = -1 * (((i - K - N) - 1) * 2);
            tempA = min(zero, tempA);
            tempB = min(zero, tempB);
            tempA = max(zero, ((i - 1) + tempA));
            tempB = max(zero, ((i - K - 1) + tempB));

            //ans += ((i - 1) + min(zero, tempA) ) * ((i - K - 1) + min(zero, tempB) );
            ans += tempA * tempB;

        }

    }

    cout << ans << endl;

    //cout << "Atcoder" << endl;

    return 0;
}