import java.util.Scanner;

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

        int n, x;
        int count = 0;
        while(true){
            n = scanner.nextInt();
            x = scanner.nextInt();
            if(n == 0 && x == 0){
                break;
            }
            count = 0;
            for(int a = n; a > 0; a--){
                for(int b = n; b > 0; b--){
                    for(int c = n; c > 0; c--){
                        if(x == (a+b+c) && a != b && b != c && c != a){
                            count++;
                        }
                    }
                }
            }
            System.out.println(count/6);
        }


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

        int n, x;
        int count = 0;
        while(true){
            n = scanner.nextInt();
            x = scanner.nextInt();
            if(n == 0 && x == 0){
                break;
            }
            count = 0;
            for(int a = n; a > 0; a--){
                for(int b = n; b > 0; b--){
                    for(int c = n; c > 0; c--){
                        if(x == (a+b+c) && a != b && b != c && c != a){
                            count++;
                        }
                    }
                }
            }
            System.out.println(count/6);
        }


        scanner.close();
    }
} Main public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        int n, x;
        int count = 0;
        while(true){
            n = scanner.nextInt();
            x = scanner.nextInt();
            if(n == 0 && x == 0){
                break;
            }
            count = 0;
            for(int a = n; a > 0; a--){
                for(int b = n; b > 0; b--){
                    for(int c = n; c > 0; c--){
                        if(x == (a+b+c) && a != b && b != c && c != a){
                            count++;
                        }
                    }
                }
            }
            System.out.println(count/6);
        }


        scanner.close();
    } main {
        Scanner scanner = new Scanner(System.in);

        int n, x;
        int count = 0;
        while(true){
            n = scanner.nextInt();
            x = scanner.nextInt();
            if(n == 0 && x == 0){
                break;
            }
            count = 0;
            for(int a = n; a > 0; a--){
                for(int b = n; b > 0; b--){
                    for(int c = n; c > 0; c--){
                        if(x == (a+b+c) && a != b && b != c && c != a){
                            count++;
                        }
                    }
                }
            }
            System.out.println(count/6);
        }


        scanner.close();
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n n x; x int count = 0; count 0 while(true){
            n = scanner.nextInt();
            x = scanner.nextInt();
            if(n == 0 && x == 0){
                break;
            }
            count = 0;
            for(int a = n; a > 0; a--){
                for(int b = n; b > 0; b--){
                    for(int c = n; c > 0; c--){
                        if(x == (a+b+c) && a != b && b != c && c != a){
                            count++;
                        }
                    }
                }
            }
            System.out.println(count/6);
        } true {
            n = scanner.nextInt();
            x = scanner.nextInt();
            if(n == 0 && x == 0){
                break;
            }
            count = 0;
            for(int a = n; a > 0; a--){
                for(int b = n; b > 0; b--){
                    for(int c = n; c > 0; c--){
                        if(x == (a+b+c) && a != b && b != c && c != a){
                            count++;
                        }
                    }
                }
            }
            System.out.println(count/6);
        } 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;
            } break; count = 0 count 0 for(int a = n; a > 0; a--){
                for(int b = n; b > 0; b--){
                    for(int c = n; c > 0; c--){
                        if(x == (a+b+c) && a != b && b != c && c != a){
                            count++;
                        }
                    }
                }
            } int a = n; int a = n; a n a > 0 a 0 a-- a-- a {
                for(int b = n; b > 0; b--){
                    for(int c = n; c > 0; c--){
                        if(x == (a+b+c) && a != b && b != c && c != a){
                            count++;
                        }
                    }
                }
            } {
                for(int b = n; b > 0; b--){
                    for(int c = n; c > 0; c--){
                        if(x == (a+b+c) && a != b && b != c && c != a){
                            count++;
                        }
                    }
                }
            } for(int b = n; b > 0; b--){
                    for(int c = n; c > 0; c--){
                        if(x == (a+b+c) && a != b && b != c && c != a){
                            count++;
                        }
                    }
                } int b = n; int b = n; b n b > 0 b 0 b-- b-- b {
                    for(int c = n; c > 0; c--){
                        if(x == (a+b+c) && a != b && b != c && c != a){
                            count++;
                        }
                    }
                } {
                    for(int c = n; c > 0; c--){
                        if(x == (a+b+c) && a != b && b != c && c != a){
                            count++;
                        }
                    }
                } for(int c = n; c > 0; c--){
                        if(x == (a+b+c) && a != b && b != c && c != a){
                            count++;
                        }
                    } int c = n; int c = n; c n c > 0 c 0 c-- c-- c {
                        if(x == (a+b+c) && a != b && b != c && c != a){
                            count++;
                        }
                    } {
                        if(x == (a+b+c) && a != b && b != c && c != a){
                            count++;
                        }
                    } if(x == (a+b+c) && a != b && b != c && c != a){
                            count++;
                        } x == (a+b+c) && a != b && b != c && c != a b != c x == (a+b+c) && a != b && b != c && c != a x == (a+b+c) x (a+b+c) a+b+c a b c a != b a b b != c b c c != a c a {
                            count++;
                        } count++ count System.out.println(count/6) System.out.println System.out System System.out count/6 count 6 scanner.close() scanner.close scanner String[] args args public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        int n, x;
        int count = 0;
        while(true){
            n = scanner.nextInt();
            x = scanner.nextInt();
            if(n == 0 && x == 0){
                break;
            }
            count = 0;
            for(int a = n; a > 0; a--){
                for(int b = n; b > 0; b--){
                    for(int c = n; c > 0; c--){
                        if(x == (a+b+c) && a != b && b != c && c != a){
                            count++;
                        }
                    }
                }
            }
            System.out.println(count/6);
        }


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

        int n, x;
        int count = 0;
        while(true){
            n = scanner.nextInt();
            x = scanner.nextInt();
            if(n == 0 && x == 0){
                break;
            }
            count = 0;
            for(int a = n; a > 0; a--){
                for(int b = n; b > 0; b--){
                    for(int c = n; c > 0; c--){
                        if(x == (a+b+c) && a != b && b != c && c != a){
                            count++;
                        }
                    }
                }
            }
            System.out.println(count/6);
        }


        scanner.close();
    }
} Main
import java.util.Scanner;

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

        int n, x;
        int count = 0;
        while(true){
            n = scanner.nextInt();
            x = scanner.nextInt();
            if(n == 0 && x == 0){
                break;
            }
            count = 0;
            for(int a = n; a > 0; a--){
                for(int b = n; b > 0; b--){
                    for(int c = n; c > 0; c--){
                        if(x == (a+b+c) && a != b && b != c && c != a){
                            count++;
                        }
                    }
                }
            }
            System.out.println(count/6);
        }


        scanner.close();
    }
}

