import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = 0;
        int x = 0;

        while(true){
            String imput = br.readLine();
            String[] strArray = imput.split(" ");
            n = Integer.parseInt(strArray[0]);
            x = Integer.parseInt(strArray[1]);

            if(n == 0 && x == 0){
                break;
            }

            int count = 0;

            for(int i = 1; i <= n; i++){
                for(int j = 1; j < i; j++){
                    for(int k = 1; k < j; k++){

                        if(i + j + k == x){
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
        }
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = 0;
        int x = 0;

        while(true){
            String imput = br.readLine();
            String[] strArray = imput.split(" ");
            n = Integer.parseInt(strArray[0]);
            x = Integer.parseInt(strArray[1]);

            if(n == 0 && x == 0){
                break;
            }

            int count = 0;

            for(int i = 1; i <= n; i++){
                for(int j = 1; j < i; j++){
                    for(int k = 1; k < j; k++){

                        if(i + j + k == x){
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
        }
    }
} Main public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = 0;
        int x = 0;

        while(true){
            String imput = br.readLine();
            String[] strArray = imput.split(" ");
            n = Integer.parseInt(strArray[0]);
            x = Integer.parseInt(strArray[1]);

            if(n == 0 && x == 0){
                break;
            }

            int count = 0;

            for(int i = 1; i <= n; i++){
                for(int j = 1; j < i; j++){
                    for(int k = 1; k < j; k++){

                        if(i + j + k == x){
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
        }
    } main {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = 0;
        int x = 0;

        while(true){
            String imput = br.readLine();
            String[] strArray = imput.split(" ");
            n = Integer.parseInt(strArray[0]);
            x = Integer.parseInt(strArray[1]);

            if(n == 0 && x == 0){
                break;
            }

            int count = 0;

            for(int i = 1; i <= n; i++){
                for(int j = 1; j < i; j++){
                    for(int k = 1; k < j; k++){

                        if(i + j + k == x){
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
        }
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int n = 0; n 0 int x = 0; x 0 while(true){
            String imput = br.readLine();
            String[] strArray = imput.split(" ");
            n = Integer.parseInt(strArray[0]);
            x = Integer.parseInt(strArray[1]);

            if(n == 0 && x == 0){
                break;
            }

            int count = 0;

            for(int i = 1; i <= n; i++){
                for(int j = 1; j < i; j++){
                    for(int k = 1; k < j; k++){

                        if(i + j + k == x){
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
        } true {
            String imput = br.readLine();
            String[] strArray = imput.split(" ");
            n = Integer.parseInt(strArray[0]);
            x = Integer.parseInt(strArray[1]);

            if(n == 0 && x == 0){
                break;
            }

            int count = 0;

            for(int i = 1; i <= n; i++){
                for(int j = 1; j < i; j++){
                    for(int k = 1; k < j; k++){

                        if(i + j + k == x){
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
        } String imput = br.readLine(); imput br.readLine() br.readLine br String[] strArray = imput.split(" "); strArray imput.split(" ") imput.split imput " " n = Integer.parseInt(strArray[0]) n Integer.parseInt(strArray[0]) Integer.parseInt Integer strArray[0] strArray 0 x = Integer.parseInt(strArray[1]) x Integer.parseInt(strArray[1]) Integer.parseInt Integer strArray[1] strArray 1 if(n == 0 && x == 0){
                break;
            } n == 0 && x == 0 n == 0 n 0 x == 0 x 0 {
                break;
            } break; int count = 0; count 0 for(int i = 1; i <= n; i++){
                for(int j = 1; j < i; j++){
                    for(int k = 1; k < j; k++){

                        if(i + j + k == x){
                            count++;
                        }
                    }
                }
            } int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
                for(int j = 1; j < i; j++){
                    for(int k = 1; k < j; k++){

                        if(i + j + k == x){
                            count++;
                        }
                    }
                }
            } {
                for(int j = 1; j < i; j++){
                    for(int k = 1; k < j; k++){

                        if(i + j + k == x){
                            count++;
                        }
                    }
                }
            } for(int j = 1; j < i; j++){
                    for(int k = 1; k < j; k++){

                        if(i + j + k == x){
                            count++;
                        }
                    }
                } int j = 1; int j = 1; j 1 j < i j i j++ j++ j {
                    for(int k = 1; k < j; k++){

                        if(i + j + k == x){
                            count++;
                        }
                    }
                } {
                    for(int k = 1; k < j; k++){

                        if(i + j + k == x){
                            count++;
                        }
                    }
                } for(int k = 1; k < j; k++){

                        if(i + j + k == x){
                            count++;
                        }
                    } int k = 1; int k = 1; k 1 k < j k j k++ k++ k {

                        if(i + j + k == x){
                            count++;
                        }
                    } {

                        if(i + j + k == x){
                            count++;
                        }
                    } if(i + j + k == x){
                            count++;
                        } i + j + k == x i + j + k i + j + k i j k x {
                            count++;
                        } count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = 0;
        int x = 0;

        while(true){
            String imput = br.readLine();
            String[] strArray = imput.split(" ");
            n = Integer.parseInt(strArray[0]);
            x = Integer.parseInt(strArray[1]);

            if(n == 0 && x == 0){
                break;
            }

            int count = 0;

            for(int i = 1; i <= n; i++){
                for(int j = 1; j < i; j++){
                    for(int k = 1; k < j; k++){

                        if(i + j + k == x){
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
        }
    }
} public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = 0;
        int x = 0;

        while(true){
            String imput = br.readLine();
            String[] strArray = imput.split(" ");
            n = Integer.parseInt(strArray[0]);
            x = Integer.parseInt(strArray[1]);

            if(n == 0 && x == 0){
                break;
            }

            int count = 0;

            for(int i = 1; i <= n; i++){
                for(int j = 1; j < i; j++){
                    for(int k = 1; k < j; k++){

                        if(i + j + k == x){
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
        }
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = 0;
        int x = 0;

        while(true){
            String imput = br.readLine();
            String[] strArray = imput.split(" ");
            n = Integer.parseInt(strArray[0]);
            x = Integer.parseInt(strArray[1]);

            if(n == 0 && x == 0){
                break;
            }

            int count = 0;

            for(int i = 1; i <= n; i++){
                for(int j = 1; j < i; j++){
                    for(int k = 1; k < j; k++){

                        if(i + j + k == x){
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
        }
    }
}