#include <bits/stdc++.h>
#define fi first
#define se second
#define is_in(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define pb push_back
#define eb emplace_back
using namespace std;
const long long INF = 1LL<<60; // 仮想的な無限大の値;
using ll = long long;
using P  = pair<int, int>;
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<ll>
#define vs vector<string>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int n = 10;
vs g(n);
int dx[] {0, 1, 0, -1};
int dy[] {1, 0, -1, 0};
vvi seen;
int dfs(int x, int y){
    int ret = 0;
    seen[x][y] = 1;
    rep(v, 4){
        int nx = x+dx[v];
        int ny = y+dy[v];
        if(!is_in(nx, 0, n)) continue;
        if(!is_in(ny, 0, n)) continue;
        if(g[nx][ny] == 'x') continue;
        if(seen[nx][ny])  continue;
        ret += 1+dfs(nx, ny);
    }
    return ret;
}

int main()
{
    ll n,k;
    cin >> n >> k;
    if(k < 0) k *= -1;
    ll cnt = 0;
    rep(i, 2*n+1){
        ll A = i+1;
        ll B = A+k;
        if(A > 2*n)  continue;
        if(B > 2*n)  continue;
        if(A-1 <= 0) continue;
        if(B-1 <= 0) continue;
        ll x = A-1;
        ll y = B-1;
        if(A > n+1) x = 2*n-A+1;
        if(B > n+1) y = 2*n-B+1;
        // int x = max(1, 2*n-A);
        // int y = max(1, 2*n-B);
        
        cnt += x*y;//(2*n-A)*(2*n-B);
    }
    cout << cnt << endl;
    return 0;
}
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
int abs(int x){
	if(x<0) return -x;
	else return x;
}
int ju(int x,int y){
	if(x<2||x>2*y) return 0;
	else return y-abs(x-(y+1));
}
int main()
{
	int n,k;scanf("%d%d",&n,&k);
	ll Ans=0;
	for(int i=2;i<=2*n;i++) Ans+=((ll)ju(i,n)*ju(i-k,n));
	printf("%lld\n",Ans);
	return 0;
}