#include <bits/stdc++.h>
using namespace std;
int main()
{
int k, s;
cin >> k >> s;
int count = 0;
for (int x = 0; x <= k; x++)
for (int y = 0; y <= k; y++)
{
int z = s - x - y;
if (z >= 0 and z <= k)
count++;
}
cout << count;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpCnsKCWludCBrLCBzOwoJY2luID4+IGsgPj4gczsKCWludCBjb3VudCA9IDA7Cglmb3IgKGludCB4ID0gMDsgeCA8PSBrOyB4KyspCgkJZm9yIChpbnQgeSA9IDA7IHkgPD0gazsgeSsrKQoJCXsKCQkJaW50IHogPSBzIC0geCAtIHk7CgkJCWlmICh6ID49IDAgYW5kIHogPD0gaykKCQkJCWNvdW50Kys7CgkJfQoJY291dCA8PCBjb3VudDsKCXJldHVybiAwOwp9