#include <bits/stdc++.h>

typedef long double ld;
#define int long long

#define gcd            __gcd
#define endl           "\n"
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define pb             push_back
#define all(x)         x.begin(), x.end()
#define f              first
#define s              second
#define lb             lower_bound
#define ub             upper_bound
#define ins            insert
#define sz(x)          (int)(x).size()
#define mk             make_pair
#define deci(x, y)     fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define PI             3.141592653589793238
#define mem0(x)        memset(x,0,sizeof x)
#define mem1(x)        memset(x,-1,sizeof x)
using namespace std;
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.f << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NITIN
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif


void solve() {
    int n,k;
    cin>>n>>k;
    map<int,int>f;
    for(int i=1;i<=n;i++){
        f[i]=i-1;
    }
    for(int i=n+1;i<=2*n;i++){
        f[i]=2*n-i+1;
    }
    int cnt=0;
    for(int i=1;i<=2*n;i++){
        cnt+=f[k+i]*f[i];
    }
    cout<<cnt<<endl;
}


int32_t main() {
    nitin;

    solve();
}
#include <bits/stdc++.h>
using namespace std;

long long pattern(long long x, long long N){
  if(x > 1 && x < N+1){
	return x - 1;
  }
  if(x > N && x < 2*N+1){
    return 2*N - x + 1;
  }
}

int main() {
	long long N, K, ans;
    ans = 0;
  	cin >> N >> K;
  	for (long long Q=2; Q<2*N+1; Q++){
      if(K + Q < 2){
        continue;
      }
      if(K + Q > 2*N+1){
        break;
      }
      else{
		ans += pattern(K + Q, N) * pattern(Q, N);
      }
	
    }
  	cout << ans;
}
