import java.util.Scanner;

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

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true) {
            int n = sc.nextInt();
            int x = sc.nextInt();
            if(n==0&&x==0)break;
            int answer = 0;
            for (int i = 1; i <= n; i++) {
                for (int j = i + 1; j <= n && i + 2 * j + 1 <= x; j++) {
                    if (j <= x - i - j && x - i - j <= n) answer++;
                }
            }
            System.out.println(answer);
        }
    }
}

