#include<iostream>
using namespace std;
int main(){
int K; cin>>K;
int S; cin>>S;
int ans = 0;
for(int A=0 ; A<=K ; A++){
for(int B=0 ; B<=K ; B++){
for(int C=0 ; C<=K ; C++){
if((A+B+C)==S){
ans++;
}
}
}
}
cout<<ans;
return 0;
}
I2luY2x1ZGU8aW9zdHJlYW0+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmludCBtYWluKCl7CgogICAgaW50IEs7IGNpbj4+SzsKICAgIGludCBTOyBjaW4+PlM7CiAgICAKICAgIGludCBhbnMgPSAwOwoKICAgIGZvcihpbnQgQT0wIDsgQTw9SyA7IEErKyl7CiAgICAgICAgZm9yKGludCBCPTAgOyBCPD1LIDsgQisrKXsKICAgICAgICAgICAgZm9yKGludCBDPTAgOyBDPD1LIDsgQysrKXsKICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgaWYoKEErQitDKT09Uyl7CiAgICAgICAgICAgICAgICAgICAgYW5zKys7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CgogICAgY291dDw8YW5zOwoKICAgIHJldHVybiAwOwp9