#include<bits/stdc++.h>

using namespace std;

#define ll long long 
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ff first
#define ss second
#define endl "\n"
#define MOD 1000000007
#define MOD1 998244353
#define inf 1e18

ll GCD(ll x,ll y){if(y==0)return x;return GCD(y,x%y);}
ll LCM(ll x,ll y){return (x*y)/(GCD(x,y));}
ll LOGK(ll x,ll k){if(x>=k)return 1+LOGK(x/k,k);return 0;}
ll MPOW( ll a, ll b, ll m) { if(b==0) return 1; ll x=MPOW(a,b/2,m); x=(x*x)%m; if(b%2==1) x=(x*a)%m; return x;}
ll MINV(ll a,ll m) {return MPOW(a,m-2,m);}

class pnc{
  ll FACT_MAX,MODU;
  vector<ll> fact;
public:
  pnc( ll n, ll m) { FACT_MAX = n; fact.resize(FACT_MAX); MODU = m; MFACT_INIT(MODU);}
  void MFACT_INIT( ll m) { fact[0]=1; for(ll i=1;i<FACT_MAX;++i) fact[i]=(i*fact[i-1])%MODU;}
  ll MFACT( ll n) { return fact[n];}
  ll PERM( ll n, ll r) { return (fact[n]*::MINV(fact[n-r],MODU))%MODU;}
  ll COMB( ll n , ll r) { return (PERM(n,r)*::MINV(fact[r],MODU))%MODU;}
};

ll calc(ll no,ll n)
{
    if(no<=n)
    {
        return no-1;
    }
    else
    {
        ll start=no-n;
        ll end=no/2;

        if(no%2)
        {
            return (end-start+1)*2;
        }
        else
        {
            return (end-start)*2+1;
        }
        
    }
    
}

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

    ll test=1;
    // cin>>test;
    while(test--)
    {
        ll n,k;
        cin>>n>>k;

        ll ans=0;

        // cout<<calc(14,10)<<endl;

        for(ll i=2*n;i>=2;i--)
        {
            ll f=i;
            ll b=f-k;

            if(b>=2 && b<=2*n)
            {
                // cout<<f<<' '<<b<<endl;
                ll no1=calc(f,n);
                ll no2=calc(b,n);

                ans+=(no1*no2);
            }
        }

        cout<<ans;
    }
}
#include<bits/stdc++.h>
using namespace std;
typedef long long D;
D n,k,ans;
D f(D x){
	return x<2||x>2*n?0:min(n-(x-n)+1,x-1);
}
int main(){
	cin>>n>>k;
	for(D i=2;i<=n*2;i++)ans+=f(i)*f(i-k);
	printf("%lld\n",ans);
	return 0;
}