#include<bits/stdc++.h>
using namespace std;
int n,k;
long long get(int x)
{
    //x-r>=1 r<=x-1 x-l<=n l>=x-n
    return min(n,x-1)-max(1,x-n)+1;
}
int main()
{
    scanf("%d%d",&n,&k);
    long long res=0;
    for(int i=2;i<=2*n;i++)
    {
        int t=i-k;
        if(t>=2&&t<=2*n)
        {
            res+=get(i)*get(t);
        }
    }
    cout<<res;
}
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define FOR(index, start, end) for(int index = start; index < end; ++index)
#define F0R(index, end) for(int index = 0; index < end; ++index)
#define RFOR(index, start, end) for(int index = start; index > end; --index)
#define FOREACH(itr, b) for(auto itr = b.begin(); itr != b.end(); ++itr)
#define RFOREACH(itr, b)  qfor(auto itr = b.rbegin(); itr != b.rend(); ++itr)

#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl
#define db3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl

#define ri(x) scanf("%d", &x)
#define ri2(x, y) scanf("%d%d", &x, &y)
#define ri3(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define rll(x) scanf("%lld", &x)

#define mp make_pair
#define sz(x) (int)x.size()
#define pf push_front
#define pb push_back

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld ,ld>;
using vi = vector<int>;
using vld = vector<ld>;
using vll = vector<ll>;

//---------------------------------------------------------------------------------------------------------------

#define INF 1000000000
#define P 257
#define M 1000000007
#define MAXN 200005


int n, k;

int cnt(int x){
    if (x <= n) return x - 1;
    return min(x - 1, abs(x - n - n) + 1);
}

void solve(){
    ll ans = 0;
    FOR(i, 2, 2 * n + 1){
        int j = i - k;
        if (1 <= j && j <= 2 * n){
            ans += (ll)cnt(i) * cnt(j);
        }
    }
    cout << ans << endl;
}

void read(){
    ri2(n, k);
}

int main(){
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);

    read();
    solve();

    /*
    int tests;
    ri(tests);
    FOR(t, 0, tests){
        read();
        solve();
    }
    */

}


