#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define ul  unsigned long int
#define pii pair<int,int>
#define pll pair<lli, lli>
#define vi  vector<int>
#define vii vector<pair<int,int>>
#define vll vector<lli>
#define pb  push_back
#define mpr  make_pair
#define ss  second
#define ff first
#define INF 1000000001
#define inf1 1000000000000000001
#define pie 3.14159265358979323846264338327950L
#define all(x) x.begin(),x.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define testcase() int tc;cin>>tc;while(tc--)
#define clean(x) memset(x,0,sizeof(x))

template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
	cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.ff << ", " << p.ss << ")"; }
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) {
	cin >> p.first;
	return cin >> p.second;
}
/// RULESSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS////
/// READ THEM ALOUD......................................................................................................
/// 1. Read the problem at least twice
/// 2. Brute force if contraints r low
/// 3. Check base cases or break case if found any T-T
/// 4. :D

lli const mod=998244353;
lli const maxn= 1e6+9;
namespace modop {
	lli madd(lli a, lli b) {
	  return (a + b) % mod;
	}
	lli msub(lli a, lli b) {
	  return (((a - b) % mod) + mod) % mod;
	}
	lli mmul(lli a, lli b) {
	  return ((a % mod) * (b % mod)) % mod;
	}
	lli mpow(lli base, lli exp) {
	  lli res = 1;
	  while (exp) {
		if (exp % 2 == 1){
			res = (res * base) % mod;
		}
		exp >>= 1;
		base = (base * base) % mod;
	  }
	  return res;
	}
	lli minv(lli base) {
	  return mpow(base, mod - 2);
	}
	lli mdiv(lli a, lli b) {
	  return mmul(a, minv(b));
	}
	lli ncr(lli n,lli r){lli ans=1;if(r>n-r)r=n-r;for(lli i=1;i<=r;i++){ans*=(n-i+1),ans=ans/i;}return ans;}
}


using namespace modop;

lli n,k;
lli ans=0;

lli ways(lli i)
{
    lli tot=i-1;
    lli sub=max(0LL,i-n-1);
    return max(0LL,tot-2*sub);
}
void solve()
{
    cin>>n>>k;
    for(lli i=k+2;i<=2*n;i++)
    {
        ans+=ways(i)*ways(i-k);
    }
    cout<<ans<<endl;
}
int main()
{
    solve();
}

#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read() {
    int x = 0, f = 1; char ch = getchar();
    while(ch<'0' || ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') { x=(x<<3)+(x<<1)+(ch^48); ch=getchar(); }
    return x * f;
}
int n,K;
int Calc(int x) {
	return min(x-1, 2*n-x+1);
}
signed main()
{
	n = read(), K = read();
	int ans = 0;
	for(int i=2;i<=2*n;++i) {
		if(i-K>=2 && i-K<=2*n) {
			ans += Calc(i)*Calc(i-K);
		}
	}
	printf("%lld\n",ans);
    return 0;
}
/*
2525 -425

10314607400
*/