#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int s,k; cin>>k>>s;
	cout << ((s+2)*(s+1)-(k>s?0:3*(s-k+1)*(s-k))+(k*2>s?0:3*(s-2*k)*(s-2*k-1)))/2;
}