#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

// template {{{  0
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int N,K;
ll f( int k ){
    return max( 0, k - 1 - 2 * max( 0, k - N - 1 ) );
}

int main() {
    Scd2(N,K);

    K = abs(K);

    ll ans = 0;
    Repe(ab,2*N+1,2){
        int cd = ab-K;
        if( 2 <= cd && cd <= 2*N ) ans += f(ab) * f(cd);
    }

    printf ("%lld\n", ans);

    return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#pragma GCC optimize ("-O3")
#define int long long
#define ld long double
#define endl "\n"

#define rep(i,begin,end) for (__typeof(end) i=begin-(begin>end); i!=(end)-(begin>end); i+=1-2*(begin>end))
#define umap unordered_map
#define pq priority_queue 
#define pb push_back
#define mp make_pair
#define fs first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define mii map<int,int>
#define pii pair<int,int>
#define vc vector
#define vi vc<int>
#define vvi vc<vi>
#define all(v) v.begin(),v.end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define w(t) int t; cin>>t; rep(tc,0,t)
#define clr(a,x) memset(a,x,sizeof a)

#define chkbit(x,i) ((x)&(1LL<<(i)))
#define setbit(x,i) ((x)|(1LL<<(i)))
#define setbits(x)  __builtin_popcountll(x)
#define zerobits(x) __builtin_ctzll(x)
#define ps(x,y) fixed<<setprecision(y)<<x
#define print(a, n) rep(i,0,n) cout<<a[i]<<" "; cout<<endl;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const int mod = 1e9+7;
const int mod2 = 998244353;
const int N = 2e5;
const int inf = 1e18;
const ld PI = 3.141592653589793;

//=====================================================


template<typename... T>
void in(T&... args) {((cin>>args), ...);}
template<typename... T>
void out(T&&... args) {((cout<<args<<" "), ...);}
template<typename... T>
void outln(T&&... args) {((cout<<args<<" "), ...); cout<<endl;}

int nxt(){int x;cin>>x;return x;}
int add(int a,int b,int mod){int res=(a+b)%mod;return (res<0)?res+mod:res;}
int mul(int a,int b,int mod){int res=(a*1LL*b)%mod;return (res<0)?res+mod:res;}
int range(int x,int y,int z) {return (x >= y && x <= z);}

struct customCompare {
    bool operator () (int x, int y) {
        return x>y;
    }
};

//=====================================================


int calc(int x){
    return ((x*(x+1))/2)%mod2;
}

void solve() {
    int n, k;
    in(n, k);

    int ans = 0;
    for(int i = 2; i <= 2*n; i++){
        int j = i - k;
        if (j >= 2 && j <= 2*n){
            ans += min(i-1, 2*n-(i-1)) * min(j-1, 2*n-(j-1));
        }
    }

    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(0); cout.tie(0);


    solve();
    // int t; cin >> t;
    // for (int tc = 1; tc <= t; tc++) {
    //     cout << "Case #" << tc << ": ";
    //     solve();
    // }

    // printclock;
    return 0;
}