import java.io.*;

public class Main{
    public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

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

            if(n == 0 && x == 0)break;
            for(int i=1; i<=n; i++){
                for(int k=1; k<=n; k++){
                    for(int w=1; w<=n; w++){
                        if(i!=k && k!=w && i!=w && (i+k+w) == x)count++;
                    }
                }
            }
            System.out.println(count / 6);
        }
    }
} import java.io.*; io.* java public class Main{
    public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

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

            if(n == 0 && x == 0)break;
            for(int i=1; i<=n; i++){
                for(int k=1; k<=n; k++){
                    for(int w=1; w<=n; w++){
                        if(i!=k && k!=w && i!=w && (i+k+w) == x)count++;
                    }
                }
            }
            System.out.println(count / 6);
        }
    }
} Main public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

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

            if(n == 0 && x == 0)break;
            for(int i=1; i<=n; i++){
                for(int k=1; k<=n; k++){
                    for(int w=1; w<=n; w++){
                        if(i!=k && k!=w && i!=w && (i+k+w) == x)count++;
                    }
                }
            }
            System.out.println(count / 6);
        }
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

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

            if(n == 0 && x == 0)break;
            for(int i=1; i<=n; i++){
                for(int k=1; k<=n; k++){
                    for(int w=1; w<=n; w++){
                        if(i!=k && k!=w && i!=w && (i+k+w) == x)count++;
                    }
                }
            }
            System.out.println(count / 6);
        }
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true){
            int count = 0;
            String[] str = br.readLine().split(" ");
            int n = Integer.parseInt(str[0]);
            int x = Integer.parseInt(str[1]);

            if(n == 0 && x == 0)break;
            for(int i=1; i<=n; i++){
                for(int k=1; k<=n; k++){
                    for(int w=1; w<=n; w++){
                        if(i!=k && k!=w && i!=w && (i+k+w) == x)count++;
                    }
                }
            }
            System.out.println(count / 6);
        } true {
            int count = 0;
            String[] str = br.readLine().split(" ");
            int n = Integer.parseInt(str[0]);
            int x = Integer.parseInt(str[1]);

            if(n == 0 && x == 0)break;
            for(int i=1; i<=n; i++){
                for(int k=1; k<=n; k++){
                    for(int w=1; w<=n; w++){
                        if(i!=k && k!=w && i!=w && (i+k+w) == x)count++;
                    }
                }
            }
            System.out.println(count / 6);
        } int count = 0; count 0 String[] str = br.readLine().split(" "); str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int n = Integer.parseInt(str[0]); n Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 int x = Integer.parseInt(str[1]); x Integer.parseInt(str[1]) Integer.parseInt Integer str[1] str 1 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++){
                for(int k=1; k<=n; k++){
                    for(int w=1; w<=n; w++){
                        if(i!=k && k!=w && i!=w && (i+k+w) == x)count++;
                    }
                }
            } int i=1; int i=1; i 1 i<=n i n i++ i++ i {
                for(int k=1; k<=n; k++){
                    for(int w=1; w<=n; w++){
                        if(i!=k && k!=w && i!=w && (i+k+w) == x)count++;
                    }
                }
            } {
                for(int k=1; k<=n; k++){
                    for(int w=1; w<=n; w++){
                        if(i!=k && k!=w && i!=w && (i+k+w) == x)count++;
                    }
                }
            } for(int k=1; k<=n; k++){
                    for(int w=1; w<=n; w++){
                        if(i!=k && k!=w && i!=w && (i+k+w) == x)count++;
                    }
                } int k=1; int k=1; k 1 k<=n k n k++ k++ k {
                    for(int w=1; w<=n; w++){
                        if(i!=k && k!=w && i!=w && (i+k+w) == x)count++;
                    }
                } {
                    for(int w=1; w<=n; w++){
                        if(i!=k && k!=w && i!=w && (i+k+w) == x)count++;
                    }
                } for(int w=1; w<=n; w++){
                        if(i!=k && k!=w && i!=w && (i+k+w) == x)count++;
                    } int w=1; int w=1; w 1 w<=n w n w++ w++ w {
                        if(i!=k && k!=w && i!=w && (i+k+w) == x)count++;
                    } {
                        if(i!=k && k!=w && i!=w && (i+k+w) == x)count++;
                    } if(i!=k && k!=w && i!=w && (i+k+w) == x)count++; i!=k && k!=w && i!=w && (i+k+w) == x i!=w i!=k && k!=w && i!=w && (i+k+w) == x i!=k i k k!=w k w i!=w i w (i+k+w) == x (i+k+w) i+k+w i k w x count++ count System.out.println(count / 6) System.out.println System.out System System.out count / 6 count 6 String[]args args public class Main{
    public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

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

            if(n == 0 && x == 0)break;
            for(int i=1; i<=n; i++){
                for(int k=1; k<=n; k++){
                    for(int w=1; w<=n; w++){
                        if(i!=k && k!=w && i!=w && (i+k+w) == x)count++;
                    }
                }
            }
            System.out.println(count / 6);
        }
    }
} public class Main{
    public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

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

            if(n == 0 && x == 0)break;
            for(int i=1; i<=n; i++){
                for(int k=1; k<=n; k++){
                    for(int w=1; w<=n; w++){
                        if(i!=k && k!=w && i!=w && (i+k+w) == x)count++;
                    }
                }
            }
            System.out.println(count / 6);
        }
    }
} Main
import java.io.*;

public class Main{
    public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

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

            if(n == 0 && x == 0)break;
            for(int i=1; i<=n; i++){
                for(int k=1; k<=n; k++){
                    for(int w=1; w<=n; w++){
                        if(i!=k && k!=w && i!=w && (i+k+w) == x)count++;
                    }
                }
            }
            System.out.println(count / 6);
        }
    }
}