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


public class Main {
    public static void main(String[] args) throws IOException{
        String[] str;
        int n,x;

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while((str = br.readLine().split(" ")) != null){
            n = Integer.parseInt(str[0]);
            x = Integer.parseInt(str[1]);

            if(n==0&&x==0){
                break;
            }

            int count=0;
            for(int i=1;i< n;i++){
                for(int j = i + 1; j < n; j++){
                    int num = x - i - j;
                    if(num > j && num <= n){
                        count++;
                    }
                }
            }
            System.out.println(count);
        }

        br.close();
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
    public static void main(String[] args) throws IOException{
        String[] str;
        int n,x;

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while((str = br.readLine().split(" ")) != null){
            n = Integer.parseInt(str[0]);
            x = Integer.parseInt(str[1]);

            if(n==0&&x==0){
                break;
            }

            int count=0;
            for(int i=1;i< n;i++){
                for(int j = i + 1; j < n; j++){
                    int num = x - i - j;
                    if(num > j && num <= n){
                        count++;
                    }
                }
            }
            System.out.println(count);
        }

        br.close();
    }
} Main public static void main(String[] args) throws IOException{
        String[] str;
        int n,x;

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while((str = br.readLine().split(" ")) != null){
            n = Integer.parseInt(str[0]);
            x = Integer.parseInt(str[1]);

            if(n==0&&x==0){
                break;
            }

            int count=0;
            for(int i=1;i< n;i++){
                for(int j = i + 1; j < n; j++){
                    int num = x - i - j;
                    if(num > j && num <= n){
                        count++;
                    }
                }
            }
            System.out.println(count);
        }

        br.close();
    } main {
        String[] str;
        int n,x;

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while((str = br.readLine().split(" ")) != null){
            n = Integer.parseInt(str[0]);
            x = Integer.parseInt(str[1]);

            if(n==0&&x==0){
                break;
            }

            int count=0;
            for(int i=1;i< n;i++){
                for(int j = i + 1; j < n; j++){
                    int num = x - i - j;
                    if(num > j && num <= n){
                        count++;
                    }
                }
            }
            System.out.println(count);
        }

        br.close();
    } String[] str; str int n n x; x BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while((str = br.readLine().split(" ")) != null){
            n = Integer.parseInt(str[0]);
            x = Integer.parseInt(str[1]);

            if(n==0&&x==0){
                break;
            }

            int count=0;
            for(int i=1;i< n;i++){
                for(int j = i + 1; j < n; j++){
                    int num = x - i - j;
                    if(num > j && num <= n){
                        count++;
                    }
                }
            }
            System.out.println(count);
        } (str = br.readLine().split(" ")) != null (str = br.readLine().split(" ")) str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " null {
            n = Integer.parseInt(str[0]);
            x = Integer.parseInt(str[1]);

            if(n==0&&x==0){
                break;
            }

            int count=0;
            for(int i=1;i< n;i++){
                for(int j = i + 1; j < n; j++){
                    int num = x - i - j;
                    if(num > j && num <= n){
                        count++;
                    }
                }
            }
            System.out.println(count);
        } n = Integer.parseInt(str[0]) n Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 x = Integer.parseInt(str[1]) x Integer.parseInt(str[1]) Integer.parseInt Integer str[1] str 1 if(n==0&&x==0){
                break;
            } n==0&&x==0 n==0 n 0 x==0 x 0 {
                break;
            } break; int count=0; count 0 for(int i=1;i< n;i++){
                for(int j = i + 1; j < n; j++){
                    int num = x - i - j;
                    if(num > j && num <= n){
                        count++;
                    }
                }
            } int i=1; int i=1; i 1 i< n i n i++ i++ i {
                for(int j = i + 1; j < n; j++){
                    int num = x - i - j;
                    if(num > j && num <= n){
                        count++;
                    }
                }
            } {
                for(int j = i + 1; j < n; j++){
                    int num = x - i - j;
                    if(num > j && num <= n){
                        count++;
                    }
                }
            } for(int j = i + 1; j < n; j++){
                    int num = x - i - j;
                    if(num > j && num <= n){
                        count++;
                    }
                } int j = i + 1; int j = i + 1; j i + 1 i 1 j < n j n j++ j++ j {
                    int num = x - i - j;
                    if(num > j && num <= n){
                        count++;
                    }
                } {
                    int num = x - i - j;
                    if(num > j && num <= n){
                        count++;
                    }
                } int num = x - i - j; num x - i - j x - i - j x i j if(num > j && num <= n){
                        count++;
                    } num > j && num <= n num > j num j num <= n num n {
                        count++;
                    } count++ count System.out.println(count) System.out.println System.out System System.out count br.close() br.close br String[] args args public class Main {
    public static void main(String[] args) throws IOException{
        String[] str;
        int n,x;

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while((str = br.readLine().split(" ")) != null){
            n = Integer.parseInt(str[0]);
            x = Integer.parseInt(str[1]);

            if(n==0&&x==0){
                break;
            }

            int count=0;
            for(int i=1;i< n;i++){
                for(int j = i + 1; j < n; j++){
                    int num = x - i - j;
                    if(num > j && num <= n){
                        count++;
                    }
                }
            }
            System.out.println(count);
        }

        br.close();
    }
} public class Main {
    public static void main(String[] args) throws IOException{
        String[] str;
        int n,x;

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while((str = br.readLine().split(" ")) != null){
            n = Integer.parseInt(str[0]);
            x = Integer.parseInt(str[1]);

            if(n==0&&x==0){
                break;
            }

            int count=0;
            for(int i=1;i< n;i++){
                for(int j = i + 1; j < n; j++){
                    int num = x - i - j;
                    if(num > j && num <= n){
                        count++;
                    }
                }
            }
            System.out.println(count);
        }

        br.close();
    }
} Main

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


public class Main {
    public static void main(String[] args) throws IOException{
        String[] str;
        int n,x;

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while((str = br.readLine().split(" ")) != null){
            n = Integer.parseInt(str[0]);
            x = Integer.parseInt(str[1]);

            if(n==0&&x==0){
                break;
            }

            int count=0;
            for(int i=1;i< n;i++){
                for(int j = i + 1; j < n; j++){
                    int num = x - i - j;
                    if(num > j && num <= n){
                        count++;
                    }
                }
            }
            System.out.println(count);
        }

        br.close();
    }
}