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

public class Main {
	public static final String EOL = System.getProperty("line.separator");
    public void exec() throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	PrintWriter out = new PrintWriter(System.out);
    	String[] s;
    	int n,x;
    	while(true) {
    		s = br.readLine().split(" ");
    		n = Integer.parseInt(s[0]);
            x = Integer.parseInt(s[1]);
            if(n == 0 && x == 0) 
            	break;
            int count = 0;
            for(int i=Math.max(x-n-(n-1),1); i<=Math.min(n-2,x/3-1); i++)
            	for (int j=Math.max(x-i-n,i+1); j<=Math.min(n-1,(x-i)/2); j++) {
            		int k = x - i - j;
            		if (j<k && k<=n) count++;
        		}
            out.println(count);
    	}
        out.flush();
    }
 
    public static void main(String[] args) throws IOException {
    	new Main().exec();
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.PrintWriter; PrintWriter java.io public class Main {
	public static final String EOL = System.getProperty("line.separator");
    public void exec() throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	PrintWriter out = new PrintWriter(System.out);
    	String[] s;
    	int n,x;
    	while(true) {
    		s = br.readLine().split(" ");
    		n = Integer.parseInt(s[0]);
            x = Integer.parseInt(s[1]);
            if(n == 0 && x == 0) 
            	break;
            int count = 0;
            for(int i=Math.max(x-n-(n-1),1); i<=Math.min(n-2,x/3-1); i++)
            	for (int j=Math.max(x-i-n,i+1); j<=Math.min(n-1,(x-i)/2); j++) {
            		int k = x - i - j;
            		if (j<k && k<=n) count++;
        		}
            out.println(count);
    	}
        out.flush();
    }
 
    public static void main(String[] args) throws IOException {
    	new Main().exec();
    }
} Main public static final String EOL = System.getProperty("line.separator"); EOL System.getProperty("line.separator") System.getProperty System "line.separator" public void exec() throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	PrintWriter out = new PrintWriter(System.out);
    	String[] s;
    	int n,x;
    	while(true) {
    		s = br.readLine().split(" ");
    		n = Integer.parseInt(s[0]);
            x = Integer.parseInt(s[1]);
            if(n == 0 && x == 0) 
            	break;
            int count = 0;
            for(int i=Math.max(x-n-(n-1),1); i<=Math.min(n-2,x/3-1); i++)
            	for (int j=Math.max(x-i-n,i+1); j<=Math.min(n-1,(x-i)/2); j++) {
            		int k = x - i - j;
            		if (j<k && k<=n) count++;
        		}
            out.println(count);
    	}
        out.flush();
    } exec {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	PrintWriter out = new PrintWriter(System.out);
    	String[] s;
    	int n,x;
    	while(true) {
    		s = br.readLine().split(" ");
    		n = Integer.parseInt(s[0]);
            x = Integer.parseInt(s[1]);
            if(n == 0 && x == 0) 
            	break;
            int count = 0;
            for(int i=Math.max(x-n-(n-1),1); i<=Math.min(n-2,x/3-1); i++)
            	for (int j=Math.max(x-i-n,i+1); j<=Math.min(n-1,(x-i)/2); j++) {
            		int k = x - i - j;
            		if (j<k && k<=n) count++;
        		}
            out.println(count);
    	}
        out.flush();
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) String[] s; s int n n x; x while(true) {
    		s = br.readLine().split(" ");
    		n = Integer.parseInt(s[0]);
            x = Integer.parseInt(s[1]);
            if(n == 0 && x == 0) 
            	break;
            int count = 0;
            for(int i=Math.max(x-n-(n-1),1); i<=Math.min(n-2,x/3-1); i++)
            	for (int j=Math.max(x-i-n,i+1); j<=Math.min(n-1,(x-i)/2); j++) {
            		int k = x - i - j;
            		if (j<k && k<=n) count++;
        		}
            out.println(count);
    	} true {
    		s = br.readLine().split(" ");
    		n = Integer.parseInt(s[0]);
            x = Integer.parseInt(s[1]);
            if(n == 0 && x == 0) 
            	break;
            int count = 0;
            for(int i=Math.max(x-n-(n-1),1); i<=Math.min(n-2,x/3-1); i++)
            	for (int j=Math.max(x-i-n,i+1); j<=Math.min(n-1,(x-i)/2); j++) {
            		int k = x - i - j;
            		if (j<k && k<=n) count++;
        		}
            out.println(count);
    	} s = br.readLine().split(" ") s br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " n = Integer.parseInt(s[0]) n Integer.parseInt(s[0]) Integer.parseInt Integer s[0] s 0 x = Integer.parseInt(s[1]) x Integer.parseInt(s[1]) Integer.parseInt Integer s[1] s 1 if(n == 0 && x == 0) 
            	break; n == 0 && x == 0 n == 0 n 0 x == 0 x 0 break; int count = 0; count 0 for(int i=Math.max(x-n-(n-1),1); i<=Math.min(n-2,x/3-1); i++)
            	for (int j=Math.max(x-i-n,i+1); j<=Math.min(n-1,(x-i)/2); j++) {
            		int k = x - i - j;
            		if (j<k && k<=n) count++;
        		} int i=Math.max(x-n-(n-1),1); int i=Math.max(x-n-(n-1),1); i Math.max(x-n-(n-1),1) Math.max Math x-n-(n-1) x-n-(n-1) x n (n-1) n 1 1 i<=Math.min(n-2,x/3-1) i Math.min(n-2,x/3-1) Math.min Math n-2 n 2 x/3-1 x/3 x 3 1 i++ i++ i for (int j=Math.max(x-i-n,i+1); j<=Math.min(n-1,(x-i)/2); j++) {
            		int k = x - i - j;
            		if (j<k && k<=n) count++;
        		} for (int j=Math.max(x-i-n,i+1); j<=Math.min(n-1,(x-i)/2); j++) {
            		int k = x - i - j;
            		if (j<k && k<=n) count++;
        		} int j=Math.max(x-i-n,i+1); int j=Math.max(x-i-n,i+1); j Math.max(x-i-n,i+1) Math.max Math x-i-n x-i-n x i n i+1 i 1 j<=Math.min(n-1,(x-i)/2) j Math.min(n-1,(x-i)/2) Math.min Math n-1 n 1 (x-i)/2 (x-i) x i 2 j++ j++ j {
            		int k = x - i - j;
            		if (j<k && k<=n) count++;
        		} {
            		int k = x - i - j;
            		if (j<k && k<=n) count++;
        		} int k = x - i - j; k x - i - j x - i - j x i j if (j<k && k<=n) count++; j<k && k<=n j<k j k k<=n k n count++ count out.println(count) out.println out count out.flush() out.flush out public static void main(String[] args) throws IOException {
    	new Main().exec();
    } main {
    	new Main().exec();
    } new Main().exec() new Main().exec new Main() String[] args args public class Main {
	public static final String EOL = System.getProperty("line.separator");
    public void exec() throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	PrintWriter out = new PrintWriter(System.out);
    	String[] s;
    	int n,x;
    	while(true) {
    		s = br.readLine().split(" ");
    		n = Integer.parseInt(s[0]);
            x = Integer.parseInt(s[1]);
            if(n == 0 && x == 0) 
            	break;
            int count = 0;
            for(int i=Math.max(x-n-(n-1),1); i<=Math.min(n-2,x/3-1); i++)
            	for (int j=Math.max(x-i-n,i+1); j<=Math.min(n-1,(x-i)/2); j++) {
            		int k = x - i - j;
            		if (j<k && k<=n) count++;
        		}
            out.println(count);
    	}
        out.flush();
    }
 
    public static void main(String[] args) throws IOException {
    	new Main().exec();
    }
} public class Main {
	public static final String EOL = System.getProperty("line.separator");
    public void exec() throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	PrintWriter out = new PrintWriter(System.out);
    	String[] s;
    	int n,x;
    	while(true) {
    		s = br.readLine().split(" ");
    		n = Integer.parseInt(s[0]);
            x = Integer.parseInt(s[1]);
            if(n == 0 && x == 0) 
            	break;
            int count = 0;
            for(int i=Math.max(x-n-(n-1),1); i<=Math.min(n-2,x/3-1); i++)
            	for (int j=Math.max(x-i-n,i+1); j<=Math.min(n-1,(x-i)/2); j++) {
            		int k = x - i - j;
            		if (j<k && k<=n) count++;
        		}
            out.println(count);
    	}
        out.flush();
    }
 
    public static void main(String[] args) throws IOException {
    	new Main().exec();
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	public static final String EOL = System.getProperty("line.separator");
    public void exec() throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	PrintWriter out = new PrintWriter(System.out);
    	String[] s;
    	int n,x;
    	while(true) {
    		s = br.readLine().split(" ");
    		n = Integer.parseInt(s[0]);
            x = Integer.parseInt(s[1]);
            if(n == 0 && x == 0) 
            	break;
            int count = 0;
            for(int i=Math.max(x-n-(n-1),1); i<=Math.min(n-2,x/3-1); i++)
            	for (int j=Math.max(x-i-n,i+1); j<=Math.min(n-1,(x-i)/2); j++) {
            		int k = x - i - j;
            		if (j<k && k<=n) count++;
        		}
            out.println(count);
    	}
        out.flush();
    }
 
    public static void main(String[] args) throws IOException {
    	new Main().exec();
    }
}