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

public class Main {

    public static void main(String[] args) throws IOException {


        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while(true) {
            
            String[] line = br.readLine().split(" ");
            int n = Integer.parseInt(line[0]);
            int x = Integer.parseInt(line[1]);
            int num = 0;
            
            if(n == 0 && x == 0) { break; }
            
            for (int a = 1; a <= n; a++){
                for (int b = 2; b <= n; b++){
                    for(int c = 3; c <= n; c++){
                        if( a+b+c == x && a < b && b < c ) {
                            num += 1;
                        }
                    }
                }           
            }
            
            System.out.println(num);
            
        }
            
                
    }


} 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 {


        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while(true) {
            
            String[] line = br.readLine().split(" ");
            int n = Integer.parseInt(line[0]);
            int x = Integer.parseInt(line[1]);
            int num = 0;
            
            if(n == 0 && x == 0) { break; }
            
            for (int a = 1; a <= n; a++){
                for (int b = 2; b <= n; b++){
                    for(int c = 3; c <= n; c++){
                        if( a+b+c == x && a < b && b < c ) {
                            num += 1;
                        }
                    }
                }           
            }
            
            System.out.println(num);
            
        }
            
                
    }


} Main public static void main(String[] args) throws IOException {


        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while(true) {
            
            String[] line = br.readLine().split(" ");
            int n = Integer.parseInt(line[0]);
            int x = Integer.parseInt(line[1]);
            int num = 0;
            
            if(n == 0 && x == 0) { break; }
            
            for (int a = 1; a <= n; a++){
                for (int b = 2; b <= n; b++){
                    for(int c = 3; c <= n; c++){
                        if( a+b+c == x && a < b && b < c ) {
                            num += 1;
                        }
                    }
                }           
            }
            
            System.out.println(num);
            
        }
            
                
    } main {


        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while(true) {
            
            String[] line = br.readLine().split(" ");
            int n = Integer.parseInt(line[0]);
            int x = Integer.parseInt(line[1]);
            int num = 0;
            
            if(n == 0 && x == 0) { break; }
            
            for (int a = 1; a <= n; a++){
                for (int b = 2; b <= n; b++){
                    for(int c = 3; c <= n; c++){
                        if( a+b+c == x && a < b && b < c ) {
                            num += 1;
                        }
                    }
                }           
            }
            
            System.out.println(num);
            
        }
            
                
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true) {
            
            String[] line = br.readLine().split(" ");
            int n = Integer.parseInt(line[0]);
            int x = Integer.parseInt(line[1]);
            int num = 0;
            
            if(n == 0 && x == 0) { break; }
            
            for (int a = 1; a <= n; a++){
                for (int b = 2; b <= n; b++){
                    for(int c = 3; c <= n; c++){
                        if( a+b+c == x && a < b && b < c ) {
                            num += 1;
                        }
                    }
                }           
            }
            
            System.out.println(num);
            
        } true {
            
            String[] line = br.readLine().split(" ");
            int n = Integer.parseInt(line[0]);
            int x = Integer.parseInt(line[1]);
            int num = 0;
            
            if(n == 0 && x == 0) { break; }
            
            for (int a = 1; a <= n; a++){
                for (int b = 2; b <= n; b++){
                    for(int c = 3; c <= n; c++){
                        if( a+b+c == x && a < b && b < c ) {
                            num += 1;
                        }
                    }
                }           
            }
            
            System.out.println(num);
            
        } String[] line = br.readLine().split(" "); line br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int n = Integer.parseInt(line[0]); n Integer.parseInt(line[0]) Integer.parseInt Integer line[0] line 0 int x = Integer.parseInt(line[1]); x Integer.parseInt(line[1]) Integer.parseInt Integer line[1] line 1 int num = 0; num 0 if(n == 0 && x == 0) { break; } n == 0 && x == 0 n == 0 n 0 x == 0 x 0 { break; } break; for (int a = 1; a <= n; a++){
                for (int b = 2; b <= n; b++){
                    for(int c = 3; c <= n; c++){
                        if( a+b+c == x && a < b && b < c ) {
                            num += 1;
                        }
                    }
                }           
            } int a = 1; int a = 1; a 1 a <= n a n a++ a++ a {
                for (int b = 2; b <= n; b++){
                    for(int c = 3; c <= n; c++){
                        if( a+b+c == x && a < b && b < c ) {
                            num += 1;
                        }
                    }
                }           
            } {
                for (int b = 2; b <= n; b++){
                    for(int c = 3; c <= n; c++){
                        if( a+b+c == x && a < b && b < c ) {
                            num += 1;
                        }
                    }
                }           
            } for (int b = 2; b <= n; b++){
                    for(int c = 3; c <= n; c++){
                        if( a+b+c == x && a < b && b < c ) {
                            num += 1;
                        }
                    }
                } int b = 2; int b = 2; b 2 b <= n b n b++ b++ b {
                    for(int c = 3; c <= n; c++){
                        if( a+b+c == x && a < b && b < c ) {
                            num += 1;
                        }
                    }
                } {
                    for(int c = 3; c <= n; c++){
                        if( a+b+c == x && a < b && b < c ) {
                            num += 1;
                        }
                    }
                } for(int c = 3; c <= n; c++){
                        if( a+b+c == x && a < b && b < c ) {
                            num += 1;
                        }
                    } int c = 3; int c = 3; c 3 c <= n c n c++ c++ c {
                        if( a+b+c == x && a < b && b < c ) {
                            num += 1;
                        }
                    } {
                        if( a+b+c == x && a < b && b < c ) {
                            num += 1;
                        }
                    } if( a+b+c == x && a < b && b < c ) {
                            num += 1;
                        } a+b+c == x && a < b && b < c a+b+c == x && a < b && b < c a+b+c == x a+b+c a+b+c a b c x a < b a b b < c b c {
                            num += 1;
                        } num += 1 num 1 System.out.println(num) System.out.println System.out System System.out num String[] args args public class Main {

    public static void main(String[] args) throws IOException {


        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while(true) {
            
            String[] line = br.readLine().split(" ");
            int n = Integer.parseInt(line[0]);
            int x = Integer.parseInt(line[1]);
            int num = 0;
            
            if(n == 0 && x == 0) { break; }
            
            for (int a = 1; a <= n; a++){
                for (int b = 2; b <= n; b++){
                    for(int c = 3; c <= n; c++){
                        if( a+b+c == x && a < b && b < c ) {
                            num += 1;
                        }
                    }
                }           
            }
            
            System.out.println(num);
            
        }
            
                
    }


} public class Main {

    public static void main(String[] args) throws IOException {


        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while(true) {
            
            String[] line = br.readLine().split(" ");
            int n = Integer.parseInt(line[0]);
            int x = Integer.parseInt(line[1]);
            int num = 0;
            
            if(n == 0 && x == 0) { break; }
            
            for (int a = 1; a <= n; a++){
                for (int b = 2; b <= n; b++){
                    for(int c = 3; c <= n; c++){
                        if( a+b+c == x && a < b && b < c ) {
                            num += 1;
                        }
                    }
                }           
            }
            
            System.out.println(num);
            
        }
            
                
    }


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

public class Main {

    public static void main(String[] args) throws IOException {


        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while(true) {
            
            String[] line = br.readLine().split(" ");
            int n = Integer.parseInt(line[0]);
            int x = Integer.parseInt(line[1]);
            int num = 0;
            
            if(n == 0 && x == 0) { break; }
            
            for (int a = 1; a <= n; a++){
                for (int b = 2; b <= n; b++){
                    for(int c = 3; c <= n; c++){
                        if( a+b+c == x && a < b && b < c ) {
                            num += 1;
                        }
                    }
                }           
            }
            
            System.out.println(num);
            
        }
            
                
    }


}