#include <iostream>
using namespace std;
int main(void){
    int n, s;
    int c; //条件を満たす場合の個数

    while(true){
        cin >> n >> s;
        if(n == 0 && s == 0) break;
        
        c = 0;
        for(int i = 0; i <= n; i++){
            for(int j = 0; j <= n; j++){
                for(int k = 0; k <= n; k++){
                    if(i + j + k == s) c++;
                }
            }
        }
        cout << c << endl;
    }
}
