#include <iostream>
#define rep(i,s,t) for (int i = s ; i <= t ; i ++)
typedef long long ll;
using namespace std;

int main()
{
    int k,s;
    ll ans = 0;
    cin>> k >> s;
    rep(i,0,k)
       rep(j,0,k)
       {
           if (s - i - j <= k && s - i - j >= 0)
              ans ++;
       }
    cout<< ans <<endl;
}
