// DeNsE - EcLiPsE //
// WHAT is DEAD may NEVER die //

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <cmath>
#include <iomanip>
#include <set>
#include <cstring>
#include <stack>
#include <sstream>
#include <queue>
#include <unordered_set>
#include <cstdlib>

using namespace std;

#define nitro ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long
#define double long double
//#define endl " \n"

const int inf = (1ll << 62) - 1;
const int mod = 998244353;
const int N = 2e5 + 10;
const double pi = 3.14159265358979323846;

int bPow(int a, int b){
    int res = 1;
    while(b) {
        if (b & 1) {
            res = (res * a) % mod;
        }
        b >>= 1;
        a = (a * a) % mod;
    }
    return res % mod;
}

int gcd(int a, int b)
{
    if(a < b)
        swap(a, b);
    if (b == 0)
        return a;
    return gcd(b, a % b);

}

vector<int> fact(N, 0ll);
void factorial(){
    fact[0] = 1, fact[1] = 1;
    for(int i = 2; i < N; i++){
        fact[i] = (fact[i - 1] * i) % mod;
    }
}

int ncr(int n, int r){
    if(r > n)
        return 0;
    int ans = fact[n] % mod;
    ans *= bPow(fact[r], mod - 2) % mod;
    ans %= mod;
    ans *= bPow(fact[n - r], mod - 2) % mod;
    ans %= mod;
    return ans;
}

vector<int> primes(N, -1), factors(N, 2);
void sieve(){
    iota(primes.begin(), primes.end(), 0);
    for (int i = 2; i * i <= N; ++i) {
        if(primes[i] == i){
            for (int j = 2 * i; j < N; j += i) {
                primes[j] = i;
                factors[j]++;
            }
        }
    }
}



void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> a(2 * n + 1, 0);
    for (int i = 1; i < a.size(); ++i) {
        a[i] = min(i - 1, 2 * n + 1 - i);
    }
    int ans = 0;
    for (int i = 1; i < a.size(); ++i) {
        int ab = i;
        int cd = ab - k;
        if(cd < a.size())
            ans += a[ab] * a[cd];
    }
    cout << ans << endl;
}

signed main(){
    nitro
    int tc = 1, test = 1;
    //cin >> tc;
    while(tc--){
        //cout << "Case #" << test++ << ": ";
        solve();
    }
}
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define f1 first
#define s2 second

#define fastio ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(x...) cerr << "[" << #x << "]: " << x << "\n";

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> pl;

ld const PI = 4*atan((ld)1);

ll f(ll n, ll x)
{
	if (x < 2 || x > 2*n)
		return 0;

	x = min(x, -x + 2*n + 2);
	return x-1;
}

int main()
{
	fastio;

	int n, k;
	cin >> n >> k;

	ll res = 0;
	for (ll x = 2; x <= 2 * n; ++x)
	{
		ll y = x - k;
		if (y >= 2)
			res += f(n, x) * f(n, y);
	}
	cout << res << '\n';

	return 0;
}
