import java.util.Scanner;

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

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int way;
        while(true){
            way = 0;
            int n = sc.nextInt();
            int x = sc.nextInt();
            if(n == 0 && x == 0) break;
            for(int i=1;i<=n;i++){
                for(int j=1;j<=n;j++){
                    if(i == j) break;
                    for(int k=1;k<=n;k++){
                        if(i == k) break;
                        if(j == k) break;
                        int sum = i + j + k;
                        if(sum == x ) way++;
                    }
                }
            }
            System.out.printf("%d\n",way);
        }
    }
}
