import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        int n, x, x1, x2, x3;
        int counter;
        while(true){
            counter = 0;
            n = scanner.nextInt();
            x = scanner.nextInt();
            if(n == 0 && x == 0)break;
            for(int i = 1; i <= n; i++){
                x1 = x;
                x1 -= i;
                if(x1 > 1){
                    for(int j = i+1; j <= n; j++){
                        x2 = x1;
                        x2 -= j;
                        if(x2 > 0){
                            for(int k = j+1; k <= n; k++){
                                x3 = x2;
                                x3 -= k;
                                if(x3 == 0)counter++;
                            }
                        }
                    }
                }
            }
            System.out.println(counter);
        }
    }
}
 import java.util.Scanner; Scanner java.util class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        int n, x, x1, x2, x3;
        int counter;
        while(true){
            counter = 0;
            n = scanner.nextInt();
            x = scanner.nextInt();
            if(n == 0 && x == 0)break;
            for(int i = 1; i <= n; i++){
                x1 = x;
                x1 -= i;
                if(x1 > 1){
                    for(int j = i+1; j <= n; j++){
                        x2 = x1;
                        x2 -= j;
                        if(x2 > 0){
                            for(int k = j+1; k <= n; k++){
                                x3 = x2;
                                x3 -= k;
                                if(x3 == 0)counter++;
                            }
                        }
                    }
                }
            }
            System.out.println(counter);
        }
    }
} Main public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        int n, x, x1, x2, x3;
        int counter;
        while(true){
            counter = 0;
            n = scanner.nextInt();
            x = scanner.nextInt();
            if(n == 0 && x == 0)break;
            for(int i = 1; i <= n; i++){
                x1 = x;
                x1 -= i;
                if(x1 > 1){
                    for(int j = i+1; j <= n; j++){
                        x2 = x1;
                        x2 -= j;
                        if(x2 > 0){
                            for(int k = j+1; k <= n; k++){
                                x3 = x2;
                                x3 -= k;
                                if(x3 == 0)counter++;
                            }
                        }
                    }
                }
            }
            System.out.println(counter);
        }
    } main {
        Scanner scanner = new Scanner(System.in);

        int n, x, x1, x2, x3;
        int counter;
        while(true){
            counter = 0;
            n = scanner.nextInt();
            x = scanner.nextInt();
            if(n == 0 && x == 0)break;
            for(int i = 1; i <= n; i++){
                x1 = x;
                x1 -= i;
                if(x1 > 1){
                    for(int j = i+1; j <= n; j++){
                        x2 = x1;
                        x2 -= j;
                        if(x2 > 0){
                            for(int k = j+1; k <= n; k++){
                                x3 = x2;
                                x3 -= k;
                                if(x3 == 0)counter++;
                            }
                        }
                    }
                }
            }
            System.out.println(counter);
        }
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n n x x x1 x1 x2 x2 x3; x3 int counter; counter while(true){
            counter = 0;
            n = scanner.nextInt();
            x = scanner.nextInt();
            if(n == 0 && x == 0)break;
            for(int i = 1; i <= n; i++){
                x1 = x;
                x1 -= i;
                if(x1 > 1){
                    for(int j = i+1; j <= n; j++){
                        x2 = x1;
                        x2 -= j;
                        if(x2 > 0){
                            for(int k = j+1; k <= n; k++){
                                x3 = x2;
                                x3 -= k;
                                if(x3 == 0)counter++;
                            }
                        }
                    }
                }
            }
            System.out.println(counter);
        } true {
            counter = 0;
            n = scanner.nextInt();
            x = scanner.nextInt();
            if(n == 0 && x == 0)break;
            for(int i = 1; i <= n; i++){
                x1 = x;
                x1 -= i;
                if(x1 > 1){
                    for(int j = i+1; j <= n; j++){
                        x2 = x1;
                        x2 -= j;
                        if(x2 > 0){
                            for(int k = j+1; k <= n; k++){
                                x3 = x2;
                                x3 -= k;
                                if(x3 == 0)counter++;
                            }
                        }
                    }
                }
            }
            System.out.println(counter);
        } counter = 0 counter 0 n = scanner.nextInt() n scanner.nextInt() scanner.nextInt scanner x = scanner.nextInt() x scanner.nextInt() scanner.nextInt scanner if(n == 0 && x == 0)break; n == 0 && x == 0 n == 0 n 0 x == 0 x 0 break; for(int i = 1; i <= n; i++){
                x1 = x;
                x1 -= i;
                if(x1 > 1){
                    for(int j = i+1; j <= n; j++){
                        x2 = x1;
                        x2 -= j;
                        if(x2 > 0){
                            for(int k = j+1; k <= n; k++){
                                x3 = x2;
                                x3 -= k;
                                if(x3 == 0)counter++;
                            }
                        }
                    }
                }
            } int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
                x1 = x;
                x1 -= i;
                if(x1 > 1){
                    for(int j = i+1; j <= n; j++){
                        x2 = x1;
                        x2 -= j;
                        if(x2 > 0){
                            for(int k = j+1; k <= n; k++){
                                x3 = x2;
                                x3 -= k;
                                if(x3 == 0)counter++;
                            }
                        }
                    }
                }
            } {
                x1 = x;
                x1 -= i;
                if(x1 > 1){
                    for(int j = i+1; j <= n; j++){
                        x2 = x1;
                        x2 -= j;
                        if(x2 > 0){
                            for(int k = j+1; k <= n; k++){
                                x3 = x2;
                                x3 -= k;
                                if(x3 == 0)counter++;
                            }
                        }
                    }
                }
            } x1 = x x1 x x1 -= i x1 i if(x1 > 1){
                    for(int j = i+1; j <= n; j++){
                        x2 = x1;
                        x2 -= j;
                        if(x2 > 0){
                            for(int k = j+1; k <= n; k++){
                                x3 = x2;
                                x3 -= k;
                                if(x3 == 0)counter++;
                            }
                        }
                    }
                } x1 > 1 x1 1 {
                    for(int j = i+1; j <= n; j++){
                        x2 = x1;
                        x2 -= j;
                        if(x2 > 0){
                            for(int k = j+1; k <= n; k++){
                                x3 = x2;
                                x3 -= k;
                                if(x3 == 0)counter++;
                            }
                        }
                    }
                } for(int j = i+1; j <= n; j++){
                        x2 = x1;
                        x2 -= j;
                        if(x2 > 0){
                            for(int k = j+1; k <= n; k++){
                                x3 = x2;
                                x3 -= k;
                                if(x3 == 0)counter++;
                            }
                        }
                    } int j = i+1; int j = i+1; j i+1 i 1 j <= n j n j++ j++ j {
                        x2 = x1;
                        x2 -= j;
                        if(x2 > 0){
                            for(int k = j+1; k <= n; k++){
                                x3 = x2;
                                x3 -= k;
                                if(x3 == 0)counter++;
                            }
                        }
                    } {
                        x2 = x1;
                        x2 -= j;
                        if(x2 > 0){
                            for(int k = j+1; k <= n; k++){
                                x3 = x2;
                                x3 -= k;
                                if(x3 == 0)counter++;
                            }
                        }
                    } x2 = x1 x2 x1 x2 -= j x2 j if(x2 > 0){
                            for(int k = j+1; k <= n; k++){
                                x3 = x2;
                                x3 -= k;
                                if(x3 == 0)counter++;
                            }
                        } x2 > 0 x2 0 {
                            for(int k = j+1; k <= n; k++){
                                x3 = x2;
                                x3 -= k;
                                if(x3 == 0)counter++;
                            }
                        } for(int k = j+1; k <= n; k++){
                                x3 = x2;
                                x3 -= k;
                                if(x3 == 0)counter++;
                            } int k = j+1; int k = j+1; k j+1 j 1 k <= n k n k++ k++ k {
                                x3 = x2;
                                x3 -= k;
                                if(x3 == 0)counter++;
                            } {
                                x3 = x2;
                                x3 -= k;
                                if(x3 == 0)counter++;
                            } x3 = x2 x3 x2 x3 -= k x3 k if(x3 == 0)counter++; x3 == 0 x3 0 counter++ counter System.out.println(counter) System.out.println System.out System System.out counter String[] args args
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        int n, x, x1, x2, x3;
        int counter;
        while(true){
            counter = 0;
            n = scanner.nextInt();
            x = scanner.nextInt();
            if(n == 0 && x == 0)break;
            for(int i = 1; i <= n; i++){
                x1 = x;
                x1 -= i;
                if(x1 > 1){
                    for(int j = i+1; j <= n; j++){
                        x2 = x1;
                        x2 -= j;
                        if(x2 > 0){
                            for(int k = j+1; k <= n; k++){
                                x3 = x2;
                                x3 -= k;
                                if(x3 == 0)counter++;
                            }
                        }
                    }
                }
            }
            System.out.println(counter);
        }
    }
}

