import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while(true){
            String[] ar = br.readLine().split(" ");
            int x = Integer.parseInt(ar[0]);
            int y = Integer.parseInt(ar[1]);
            if(x == 0 && y == 0){ break;
            }
            int ans = 0;
            for(int i = 1; i <= x; i++){
                for(int j = 1; j <= x; j++){
                    if(i == j){break;
                    }
                    for(int k = 1; k <= x; k++){
                        if(i == k || j == k){ break;
                        }
                        if(i+j+k == y){
                            ans++;
                        }
                    }
                }
            }
            System.out.println(ans);
        }
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while(true){
            String[] ar = br.readLine().split(" ");
            int x = Integer.parseInt(ar[0]);
            int y = Integer.parseInt(ar[1]);
            if(x == 0 && y == 0){ break;
            }
            int ans = 0;
            for(int i = 1; i <= x; i++){
                for(int j = 1; j <= x; j++){
                    if(i == j){break;
                    }
                    for(int k = 1; k <= x; k++){
                        if(i == k || j == k){ break;
                        }
                        if(i+j+k == y){
                            ans++;
                        }
                    }
                }
            }
            System.out.println(ans);
        }
    }
} Main public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while(true){
            String[] ar = br.readLine().split(" ");
            int x = Integer.parseInt(ar[0]);
            int y = Integer.parseInt(ar[1]);
            if(x == 0 && y == 0){ break;
            }
            int ans = 0;
            for(int i = 1; i <= x; i++){
                for(int j = 1; j <= x; j++){
                    if(i == j){break;
                    }
                    for(int k = 1; k <= x; k++){
                        if(i == k || j == k){ break;
                        }
                        if(i+j+k == y){
                            ans++;
                        }
                    }
                }
            }
            System.out.println(ans);
        }
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while(true){
            String[] ar = br.readLine().split(" ");
            int x = Integer.parseInt(ar[0]);
            int y = Integer.parseInt(ar[1]);
            if(x == 0 && y == 0){ break;
            }
            int ans = 0;
            for(int i = 1; i <= x; i++){
                for(int j = 1; j <= x; j++){
                    if(i == j){break;
                    }
                    for(int k = 1; k <= x; k++){
                        if(i == k || j == k){ break;
                        }
                        if(i+j+k == y){
                            ans++;
                        }
                    }
                }
            }
            System.out.println(ans);
        }
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true){
            String[] ar = br.readLine().split(" ");
            int x = Integer.parseInt(ar[0]);
            int y = Integer.parseInt(ar[1]);
            if(x == 0 && y == 0){ break;
            }
            int ans = 0;
            for(int i = 1; i <= x; i++){
                for(int j = 1; j <= x; j++){
                    if(i == j){break;
                    }
                    for(int k = 1; k <= x; k++){
                        if(i == k || j == k){ break;
                        }
                        if(i+j+k == y){
                            ans++;
                        }
                    }
                }
            }
            System.out.println(ans);
        } true {
            String[] ar = br.readLine().split(" ");
            int x = Integer.parseInt(ar[0]);
            int y = Integer.parseInt(ar[1]);
            if(x == 0 && y == 0){ break;
            }
            int ans = 0;
            for(int i = 1; i <= x; i++){
                for(int j = 1; j <= x; j++){
                    if(i == j){break;
                    }
                    for(int k = 1; k <= x; k++){
                        if(i == k || j == k){ break;
                        }
                        if(i+j+k == y){
                            ans++;
                        }
                    }
                }
            }
            System.out.println(ans);
        } String[] ar = br.readLine().split(" "); ar br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int x = Integer.parseInt(ar[0]); x Integer.parseInt(ar[0]) Integer.parseInt Integer ar[0] ar 0 int y = Integer.parseInt(ar[1]); y Integer.parseInt(ar[1]) Integer.parseInt Integer ar[1] ar 1 if(x == 0 && y == 0){ break;
            } x == 0 && y == 0 x == 0 x 0 y == 0 y 0 { break;
            } break; int ans = 0; ans 0 for(int i = 1; i <= x; i++){
                for(int j = 1; j <= x; j++){
                    if(i == j){break;
                    }
                    for(int k = 1; k <= x; k++){
                        if(i == k || j == k){ break;
                        }
                        if(i+j+k == y){
                            ans++;
                        }
                    }
                }
            } int i = 1; int i = 1; i 1 i <= x i x i++ i++ i {
                for(int j = 1; j <= x; j++){
                    if(i == j){break;
                    }
                    for(int k = 1; k <= x; k++){
                        if(i == k || j == k){ break;
                        }
                        if(i+j+k == y){
                            ans++;
                        }
                    }
                }
            } {
                for(int j = 1; j <= x; j++){
                    if(i == j){break;
                    }
                    for(int k = 1; k <= x; k++){
                        if(i == k || j == k){ break;
                        }
                        if(i+j+k == y){
                            ans++;
                        }
                    }
                }
            } for(int j = 1; j <= x; j++){
                    if(i == j){break;
                    }
                    for(int k = 1; k <= x; k++){
                        if(i == k || j == k){ break;
                        }
                        if(i+j+k == y){
                            ans++;
                        }
                    }
                } int j = 1; int j = 1; j 1 j <= x j x j++ j++ j {
                    if(i == j){break;
                    }
                    for(int k = 1; k <= x; k++){
                        if(i == k || j == k){ break;
                        }
                        if(i+j+k == y){
                            ans++;
                        }
                    }
                } {
                    if(i == j){break;
                    }
                    for(int k = 1; k <= x; k++){
                        if(i == k || j == k){ break;
                        }
                        if(i+j+k == y){
                            ans++;
                        }
                    }
                } if(i == j){break;
                    } i == j i j {break;
                    } break; for(int k = 1; k <= x; k++){
                        if(i == k || j == k){ break;
                        }
                        if(i+j+k == y){
                            ans++;
                        }
                    } int k = 1; int k = 1; k 1 k <= x k x k++ k++ k {
                        if(i == k || j == k){ break;
                        }
                        if(i+j+k == y){
                            ans++;
                        }
                    } {
                        if(i == k || j == k){ break;
                        }
                        if(i+j+k == y){
                            ans++;
                        }
                    } if(i == k || j == k){ break;
                        } i == k || j == k i == k i k j == k j k { break;
                        } break; if(i+j+k == y){
                            ans++;
                        } i+j+k == y i+j+k i+j+k i j k y {
                            ans++;
                        } ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while(true){
            String[] ar = br.readLine().split(" ");
            int x = Integer.parseInt(ar[0]);
            int y = Integer.parseInt(ar[1]);
            if(x == 0 && y == 0){ break;
            }
            int ans = 0;
            for(int i = 1; i <= x; i++){
                for(int j = 1; j <= x; j++){
                    if(i == j){break;
                    }
                    for(int k = 1; k <= x; k++){
                        if(i == k || j == k){ break;
                        }
                        if(i+j+k == y){
                            ans++;
                        }
                    }
                }
            }
            System.out.println(ans);
        }
    }
} public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while(true){
            String[] ar = br.readLine().split(" ");
            int x = Integer.parseInt(ar[0]);
            int y = Integer.parseInt(ar[1]);
            if(x == 0 && y == 0){ break;
            }
            int ans = 0;
            for(int i = 1; i <= x; i++){
                for(int j = 1; j <= x; j++){
                    if(i == j){break;
                    }
                    for(int k = 1; k <= x; k++){
                        if(i == k || j == k){ break;
                        }
                        if(i+j+k == y){
                            ans++;
                        }
                    }
                }
            }
            System.out.println(ans);
        }
    }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while(true){
            String[] ar = br.readLine().split(" ");
            int x = Integer.parseInt(ar[0]);
            int y = Integer.parseInt(ar[1]);
            if(x == 0 && y == 0){ break;
            }
            int ans = 0;
            for(int i = 1; i <= x; i++){
                for(int j = 1; j <= x; j++){
                    if(i == j){break;
                    }
                    for(int k = 1; k <= x; k++){
                        if(i == k || j == k){ break;
                        }
                        if(i+j+k == y){
                            ans++;
                        }
                    }
                }
            }
            System.out.println(ans);
        }
    }
}