#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
struct Edge {
    int to, cost;
    Edge(){};
    Edge(int to, int cost): to(to), cost(cost){};
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

int main() {
    cin.tie(0);
    cin.sync_with_stdio(0);

    ll n, k;
    cin >> n >> k;

    ll ans = 0;
    ll a, b;
    for (ll i = 2; i <= 2*n; i++) {
        if (i - k < 2 || 2*n < i - k) continue;

        if (i > n) a = 2*n - i + 1; // n - (i - n) + 1
        else a = i-2+1;

        if (i - k > n) b = 2*n -(i - k) + 1;
        else b = i-k-1;

        ans += a * b;
    }
    cout << ans << endl;
}
// Template begins
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <math.h>
#include <iomanip>
#include <queue> 
#include <string.h>
#include <string>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define fo(i,a,b) for(i=a;i<=b;i++)
#define all(v) (v).begin(),(v).end()
#define sort0(v) sort(all(v))
#define lbb(a,b,arr,x) lower_bound(arr+a,arr+b+1,x)-arr
#define ubb(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-arr
#define freq(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-lower_bound(arr+a,arr+b+1,x)
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl
#define max3(a,b,c) max(max((a),(b)),(c))
#define max4(a,b,c,d) max(max((a),(b)),max((c),(d)))
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define printp(x) cout << x.ff << " " << x.ss << endl
 
const ll mod=998244353;
#define inf 9999999999999
#define MAXN   100001 
  
// stores smallest prime factor for every number 
 
 
ll inv(ll i){if(i==1) return 1;return (mod-((mod/i)*inv(mod%i))%mod)%mod;}
 
ll gcd(ll a,ll b){if(a==0) return b;return gcd(b,b%a);}
inline void fastio(){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
// Template ends'
ll factorial[1000002];
const int MN = 2e5+7;
ll val(ll a){
    return ((a*(a+1))/2)%mod;
}
void solve(){
    
    ll n,k; cin>>n>>k;
    ll a,b;
    k=abs(k);
    ll ans=0;
    for(int i=2;i<=2*n;i++){
        a=i;
        b=a-k;
        if( b>=2)
            ans= ans+min(a-1,2*n + 1 - a)*min(b-1,2*n + 1 - b);
        
    }
    cout<<ans<<endl;
}
int main(){
    fastio();
    //write code
    int t=1;
    while(t--){
        solve();
    }
    return 0;
}