import java.util.Scanner;
public class Main {
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int n,x,a=0;
            n = sc.nextInt();
            x = sc.nextInt();
            if(n==0&&x==0)break;
            for(int i=1;i<n-1;i++){
                for(int j=i+1;j<n;j++){
                    int c = x - i - j;
                    if(c>j&&c<=n){
                        a++;
                    }
                }
            }
            System.out.println(a);
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int n,x,a=0;
            n = sc.nextInt();
            x = sc.nextInt();
            if(n==0&&x==0)break;
            for(int i=1;i<n-1;i++){
                for(int j=i+1;j<n;j++){
                    int c = x - i - j;
                    if(c>j&&c<=n){
                        a++;
                    }
                }
            }
            System.out.println(a);
        }
    }
} Main public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int n,x,a=0;
            n = sc.nextInt();
            x = sc.nextInt();
            if(n==0&&x==0)break;
            for(int i=1;i<n-1;i++){
                for(int j=i+1;j<n;j++){
                    int c = x - i - j;
                    if(c>j&&c<=n){
                        a++;
                    }
                }
            }
            System.out.println(a);
        }
    } main {
        Scanner sc = new Scanner(System.in);
        while(true){
            int n,x,a=0;
            n = sc.nextInt();
            x = sc.nextInt();
            if(n==0&&x==0)break;
            for(int i=1;i<n-1;i++){
                for(int j=i+1;j<n;j++){
                    int c = x - i - j;
                    if(c>j&&c<=n){
                        a++;
                    }
                }
            }
            System.out.println(a);
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true){
            int n,x,a=0;
            n = sc.nextInt();
            x = sc.nextInt();
            if(n==0&&x==0)break;
            for(int i=1;i<n-1;i++){
                for(int j=i+1;j<n;j++){
                    int c = x - i - j;
                    if(c>j&&c<=n){
                        a++;
                    }
                }
            }
            System.out.println(a);
        } true {
            int n,x,a=0;
            n = sc.nextInt();
            x = sc.nextInt();
            if(n==0&&x==0)break;
            for(int i=1;i<n-1;i++){
                for(int j=i+1;j<n;j++){
                    int c = x - i - j;
                    if(c>j&&c<=n){
                        a++;
                    }
                }
            }
            System.out.println(a);
        } int n n x x a=0; a 0 n = sc.nextInt() n sc.nextInt() sc.nextInt sc x = sc.nextInt() x sc.nextInt() sc.nextInt sc 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-1;i++){
                for(int j=i+1;j<n;j++){
                    int c = x - i - j;
                    if(c>j&&c<=n){
                        a++;
                    }
                }
            } int i=1; int i=1; i 1 i<n-1 i n-1 n 1 i++ i++ i {
                for(int j=i+1;j<n;j++){
                    int c = x - i - j;
                    if(c>j&&c<=n){
                        a++;
                    }
                }
            } {
                for(int j=i+1;j<n;j++){
                    int c = x - i - j;
                    if(c>j&&c<=n){
                        a++;
                    }
                }
            } for(int j=i+1;j<n;j++){
                    int c = x - i - j;
                    if(c>j&&c<=n){
                        a++;
                    }
                } int j=i+1; int j=i+1; j i+1 i 1 j<n j n j++ j++ j {
                    int c = x - i - j;
                    if(c>j&&c<=n){
                        a++;
                    }
                } {
                    int c = x - i - j;
                    if(c>j&&c<=n){
                        a++;
                    }
                } int c = x - i - j; c x - i - j x - i - j x i j if(c>j&&c<=n){
                        a++;
                    } c>j&&c<=n c>j c j c<=n c n {
                        a++;
                    } a++ a System.out.println(a) System.out.println System.out System System.out a String[]args args public class Main {
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int n,x,a=0;
            n = sc.nextInt();
            x = sc.nextInt();
            if(n==0&&x==0)break;
            for(int i=1;i<n-1;i++){
                for(int j=i+1;j<n;j++){
                    int c = x - i - j;
                    if(c>j&&c<=n){
                        a++;
                    }
                }
            }
            System.out.println(a);
        }
    }
} public class Main {
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int n,x,a=0;
            n = sc.nextInt();
            x = sc.nextInt();
            if(n==0&&x==0)break;
            for(int i=1;i<n-1;i++){
                for(int j=i+1;j<n;j++){
                    int c = x - i - j;
                    if(c>j&&c<=n){
                        a++;
                    }
                }
            }
            System.out.println(a);
        }
    }
} Main
import java.util.Scanner;
public class Main {
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int n,x,a=0;
            n = sc.nextInt();
            x = sc.nextInt();
            if(n==0&&x==0)break;
            for(int i=1;i<n-1;i++){
                for(int j=i+1;j<n;j++){
                    int c = x - i - j;
                    if(c>j&&c<=n){
                        a++;
                    }
                }
            }
            System.out.println(a);
        }
    }
}
