import java.io.*;
import java.util.*;

public class Main { 
	public static void main(String args[]) throws IOException{
		Scanner scr = new Scanner(System.in);
		while (true){
		    try{
				String[] str = scr.nextLine().split(" ", 0);
				int n = Integer.parseInt(str[0]);
				int x = Integer.parseInt(str[1]);
				if (n==0 && x==0) break; //??\?????????
				System.out.println( SearchTrio(n, x) );
			}catch(Exception e){
				System.err.println("Exception");
				break;
			}
        }
		/*String[] str = scr.nextLine().split(" ", 0);
		System.out.println( SearchPair(Integer.parseInt(str[0]),
				Integer.parseInt(str[1]), Integer.parseInt(str[2])) );*/
		scr.close();
	}
	
	
	private static int SearchTrio(int n, int x){
		int r=0;
	    for(int i=1; i<(x/3); i++){
	    	r += SearchPair(i+1, n, x-i);
		}
	    return r;
	}
	
	// min??\???max??\??????2??°????????§x???????????????
	private static int SearchPair(int min, int max, int x){
		if( min+max <= x) return Math.max((max - x/2), 0);
		else return Math.max((CeilDiv(x,2) - min),0);
	}
	private static int CeilDiv(int divided, int divider){
		if(divided%2==0) return divided/divider;
		else return divided/divider+1;
	}
} import java.io.*; io.* java import java.util.*; util.* java public class Main { 
	public static void main(String args[]) throws IOException{
		Scanner scr = new Scanner(System.in);
		while (true){
		    try{
				String[] str = scr.nextLine().split(" ", 0);
				int n = Integer.parseInt(str[0]);
				int x = Integer.parseInt(str[1]);
				if (n==0 && x==0) break; //??\?????????
				System.out.println( SearchTrio(n, x) );
			}catch(Exception e){
				System.err.println("Exception");
				break;
			}
        }
		/*String[] str = scr.nextLine().split(" ", 0);
		System.out.println( SearchPair(Integer.parseInt(str[0]),
				Integer.parseInt(str[1]), Integer.parseInt(str[2])) );*/
		scr.close();
	}
	
	
	private static int SearchTrio(int n, int x){
		int r=0;
	    for(int i=1; i<(x/3); i++){
	    	r += SearchPair(i+1, n, x-i);
		}
	    return r;
	}
	
	// min??\???max??\??????2??°????????§x???????????????
	private static int SearchPair(int min, int max, int x){
		if( min+max <= x) return Math.max((max - x/2), 0);
		else return Math.max((CeilDiv(x,2) - min),0);
	}
	private static int CeilDiv(int divided, int divider){
		if(divided%2==0) return divided/divider;
		else return divided/divider+1;
	}
} Main public static void main(String args[]) throws IOException{
		Scanner scr = new Scanner(System.in);
		while (true){
		    try{
				String[] str = scr.nextLine().split(" ", 0);
				int n = Integer.parseInt(str[0]);
				int x = Integer.parseInt(str[1]);
				if (n==0 && x==0) break; //??\?????????
				System.out.println( SearchTrio(n, x) );
			}catch(Exception e){
				System.err.println("Exception");
				break;
			}
        }
		/*String[] str = scr.nextLine().split(" ", 0);
		System.out.println( SearchPair(Integer.parseInt(str[0]),
				Integer.parseInt(str[1]), Integer.parseInt(str[2])) );*/
		scr.close();
	} main {
		Scanner scr = new Scanner(System.in);
		while (true){
		    try{
				String[] str = scr.nextLine().split(" ", 0);
				int n = Integer.parseInt(str[0]);
				int x = Integer.parseInt(str[1]);
				if (n==0 && x==0) break; //??\?????????
				System.out.println( SearchTrio(n, x) );
			}catch(Exception e){
				System.err.println("Exception");
				break;
			}
        }
		/*String[] str = scr.nextLine().split(" ", 0);
		System.out.println( SearchPair(Integer.parseInt(str[0]),
				Integer.parseInt(str[1]), Integer.parseInt(str[2])) );*/
		scr.close();
	} Scanner scr = new Scanner(System.in); scr new Scanner(System.in) while (true){
		    try{
				String[] str = scr.nextLine().split(" ", 0);
				int n = Integer.parseInt(str[0]);
				int x = Integer.parseInt(str[1]);
				if (n==0 && x==0) break; //??\?????????
				System.out.println( SearchTrio(n, x) );
			}catch(Exception e){
				System.err.println("Exception");
				break;
			}
        } true {
		    try{
				String[] str = scr.nextLine().split(" ", 0);
				int n = Integer.parseInt(str[0]);
				int x = Integer.parseInt(str[1]);
				if (n==0 && x==0) break; //??\?????????
				System.out.println( SearchTrio(n, x) );
			}catch(Exception e){
				System.err.println("Exception");
				break;
			}
        } try{
				String[] str = scr.nextLine().split(" ", 0);
				int n = Integer.parseInt(str[0]);
				int x = Integer.parseInt(str[1]);
				if (n==0 && x==0) break; //??\?????????
				System.out.println( SearchTrio(n, x) );
			}catch(Exception e){
				System.err.println("Exception");
				break;
			} catch(Exception e){
				System.err.println("Exception");
				break;
			} Exception e {
				System.err.println("Exception");
				break;
			} System.err.println("Exception") System.err.println System.err System System.err "Exception" break; {
				String[] str = scr.nextLine().split(" ", 0);
				int n = Integer.parseInt(str[0]);
				int x = Integer.parseInt(str[1]);
				if (n==0 && x==0) break; //??\?????????
				System.out.println( SearchTrio(n, x) );
			} String[] str = scr.nextLine().split(" ", 0); str scr.nextLine().split(" ", 0) scr.nextLine().split scr.nextLine() scr.nextLine scr " " 0 int n = Integer.parseInt(str[0]); n Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 int 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; //??\????????? System.out.println( SearchTrio(n, x) ) System.out.println System.out System System.out SearchTrio(n, x) SearchTrio n x scr.close() scr.close scr String args[] args private static int SearchTrio(int n, int x){
		int r=0;
	    for(int i=1; i<(x/3); i++){
	    	r += SearchPair(i+1, n, x-i);
		}
	    return r;
	} SearchTrio {
		int r=0;
	    for(int i=1; i<(x/3); i++){
	    	r += SearchPair(i+1, n, x-i);
		}
	    return r;
	} int r=0; r 0 for(int i=1; i<(x/3); i++){
	    	r += SearchPair(i+1, n, x-i);
		} int i=1; int i=1; i 1 i<(x/3) i (x/3) x 3 i++ i++ i {
	    	r += SearchPair(i+1, n, x-i);
		} {
	    	r += SearchPair(i+1, n, x-i);
		} r += SearchPair(i+1, n, x-i) r SearchPair(i+1, n, x-i) SearchPair i+1 i 1 n x-i x i return r; r int n n int x x // min??\???max??\??????2??°????????§x???????????????
	private static int SearchPair(int min, int max, int x){
		if( min+max <= x) return Math.max((max - x/2), 0);
		else return Math.max((CeilDiv(x,2) - min),0);
	} SearchPair {
		if( min+max <= x) return Math.max((max - x/2), 0);
		else return Math.max((CeilDiv(x,2) - min),0);
	} if( min+max <= x) return Math.max((max - x/2), 0);
		else return Math.max((CeilDiv(x,2) - min),0); min+max <= x min+max min max x return Math.max((max - x/2), 0); Math.max((max - x/2), 0) Math.max Math (max - x/2) max x/2 x 2 0 return Math.max((CeilDiv(x,2) - min),0); Math.max((CeilDiv(x,2) - min),0) Math.max Math (CeilDiv(x,2) - min) CeilDiv(x,2) CeilDiv x 2 min 0 int min min int max max int x x private static int CeilDiv(int divided, int divider){
		if(divided%2==0) return divided/divider;
		else return divided/divider+1;
	} CeilDiv {
		if(divided%2==0) return divided/divider;
		else return divided/divider+1;
	} if(divided%2==0) return divided/divider;
		else return divided/divider+1; divided%2==0 divided%2 divided 2 0 return divided/divider; divided/divider divided divider return divided/divider+1; divided/divider+1 divided/divider divided divider 1 int divided divided int divider divider public class Main { 
	public static void main(String args[]) throws IOException{
		Scanner scr = new Scanner(System.in);
		while (true){
		    try{
				String[] str = scr.nextLine().split(" ", 0);
				int n = Integer.parseInt(str[0]);
				int x = Integer.parseInt(str[1]);
				if (n==0 && x==0) break; //??\?????????
				System.out.println( SearchTrio(n, x) );
			}catch(Exception e){
				System.err.println("Exception");
				break;
			}
        }
		/*String[] str = scr.nextLine().split(" ", 0);
		System.out.println( SearchPair(Integer.parseInt(str[0]),
				Integer.parseInt(str[1]), Integer.parseInt(str[2])) );*/
		scr.close();
	}
	
	
	private static int SearchTrio(int n, int x){
		int r=0;
	    for(int i=1; i<(x/3); i++){
	    	r += SearchPair(i+1, n, x-i);
		}
	    return r;
	}
	
	// min??\???max??\??????2??°????????§x???????????????
	private static int SearchPair(int min, int max, int x){
		if( min+max <= x) return Math.max((max - x/2), 0);
		else return Math.max((CeilDiv(x,2) - min),0);
	}
	private static int CeilDiv(int divided, int divider){
		if(divided%2==0) return divided/divider;
		else return divided/divider+1;
	}
} public class Main { 
	public static void main(String args[]) throws IOException{
		Scanner scr = new Scanner(System.in);
		while (true){
		    try{
				String[] str = scr.nextLine().split(" ", 0);
				int n = Integer.parseInt(str[0]);
				int x = Integer.parseInt(str[1]);
				if (n==0 && x==0) break; //??\?????????
				System.out.println( SearchTrio(n, x) );
			}catch(Exception e){
				System.err.println("Exception");
				break;
			}
        }
		/*String[] str = scr.nextLine().split(" ", 0);
		System.out.println( SearchPair(Integer.parseInt(str[0]),
				Integer.parseInt(str[1]), Integer.parseInt(str[2])) );*/
		scr.close();
	}
	
	
	private static int SearchTrio(int n, int x){
		int r=0;
	    for(int i=1; i<(x/3); i++){
	    	r += SearchPair(i+1, n, x-i);
		}
	    return r;
	}
	
	// min??\???max??\??????2??°????????§x???????????????
	private static int SearchPair(int min, int max, int x){
		if( min+max <= x) return Math.max((max - x/2), 0);
		else return Math.max((CeilDiv(x,2) - min),0);
	}
	private static int CeilDiv(int divided, int divider){
		if(divided%2==0) return divided/divider;
		else return divided/divider+1;
	}
} Main
import java.io.*;
import java.util.*;

public class Main { 
	public static void main(String args[]) throws IOException{
		Scanner scr = new Scanner(System.in);
		while (true){
		    try{
				String[] str = scr.nextLine().split(" ", 0);
				int n = Integer.parseInt(str[0]);
				int x = Integer.parseInt(str[1]);
				if (n==0 && x==0) break; //??\?????????
				System.out.println( SearchTrio(n, x) );
			}catch(Exception e){
				System.err.println("Exception");
				break;
			}
        }
		/*String[] str = scr.nextLine().split(" ", 0);
		System.out.println( SearchPair(Integer.parseInt(str[0]),
				Integer.parseInt(str[1]), Integer.parseInt(str[2])) );*/
		scr.close();
	}
	
	
	private static int SearchTrio(int n, int x){
		int r=0;
	    for(int i=1; i<(x/3); i++){
	    	r += SearchPair(i+1, n, x-i);
		}
	    return r;
	}
	
	// min??\???max??\??????2??°????????§x???????????????
	private static int SearchPair(int min, int max, int x){
		if( min+max <= x) return Math.max((max - x/2), 0);
		else return Math.max((CeilDiv(x,2) - min),0);
	}
	private static int CeilDiv(int divided, int divider){
		if(divided%2==0) return divided/divider;
		else return divided/divider+1;
	}
}