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[] input = br.readLine().split(" ");
		
		int n = Integer.parseInt(input[0]);
        int x = Integer.parseInt(input[1]);
        int cnt = 0;
        if(x == 0 && n == 0){
            break;
        }else{
            for(int i = 1; i <= n; i++ ){
            	
                for(int l = i + 1; l <= n; l++ ){
                	
                    for(int k = l + 1; k <= n; k++ ){
                    	//System.out.println(i+"+"+l+"+"+k);
                        if((i + l + k) == x){
                            cnt++;
                        }
                    }
                }
            }
    }//while 
        System.out.println(cnt);
		
		}
	}
	
} 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[] input = br.readLine().split(" ");
		
		int n = Integer.parseInt(input[0]);
        int x = Integer.parseInt(input[1]);
        int cnt = 0;
        if(x == 0 && n == 0){
            break;
        }else{
            for(int i = 1; i <= n; i++ ){
            	
                for(int l = i + 1; l <= n; l++ ){
                	
                    for(int k = l + 1; k <= n; k++ ){
                    	//System.out.println(i+"+"+l+"+"+k);
                        if((i + l + k) == x){
                            cnt++;
                        }
                    }
                }
            }
    }//while 
        System.out.println(cnt);
		
		}
	}
	
} Main public static void main(String[] args) throws IOException{
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
		
		String[] input = br.readLine().split(" ");
		
		int n = Integer.parseInt(input[0]);
        int x = Integer.parseInt(input[1]);
        int cnt = 0;
        if(x == 0 && n == 0){
            break;
        }else{
            for(int i = 1; i <= n; i++ ){
            	
                for(int l = i + 1; l <= n; l++ ){
                	
                    for(int k = l + 1; k <= n; k++ ){
                    	//System.out.println(i+"+"+l+"+"+k);
                        if((i + l + k) == x){
                            cnt++;
                        }
                    }
                }
            }
    }//while 
        System.out.println(cnt);
		
		}
	} main {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
		
		String[] input = br.readLine().split(" ");
		
		int n = Integer.parseInt(input[0]);
        int x = Integer.parseInt(input[1]);
        int cnt = 0;
        if(x == 0 && n == 0){
            break;
        }else{
            for(int i = 1; i <= n; i++ ){
            	
                for(int l = i + 1; l <= n; l++ ){
                	
                    for(int k = l + 1; k <= n; k++ ){
                    	//System.out.println(i+"+"+l+"+"+k);
                        if((i + l + k) == x){
                            cnt++;
                        }
                    }
                }
            }
    }//while 
        System.out.println(cnt);
		
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true){
		
		String[] input = br.readLine().split(" ");
		
		int n = Integer.parseInt(input[0]);
        int x = Integer.parseInt(input[1]);
        int cnt = 0;
        if(x == 0 && n == 0){
            break;
        }else{
            for(int i = 1; i <= n; i++ ){
            	
                for(int l = i + 1; l <= n; l++ ){
                	
                    for(int k = l + 1; k <= n; k++ ){
                    	//System.out.println(i+"+"+l+"+"+k);
                        if((i + l + k) == x){
                            cnt++;
                        }
                    }
                }
            }
    }//while 
        System.out.println(cnt);
		
		} true {
		
		String[] input = br.readLine().split(" ");
		
		int n = Integer.parseInt(input[0]);
        int x = Integer.parseInt(input[1]);
        int cnt = 0;
        if(x == 0 && n == 0){
            break;
        }else{
            for(int i = 1; i <= n; i++ ){
            	
                for(int l = i + 1; l <= n; l++ ){
                	
                    for(int k = l + 1; k <= n; k++ ){
                    	//System.out.println(i+"+"+l+"+"+k);
                        if((i + l + k) == x){
                            cnt++;
                        }
                    }
                }
            }
    }//while 
        System.out.println(cnt);
		
		} String[] input = br.readLine().split(" "); input br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int n = Integer.parseInt(input[0]); n Integer.parseInt(input[0]) Integer.parseInt Integer input[0] input 0 int x = Integer.parseInt(input[1]); x Integer.parseInt(input[1]) Integer.parseInt Integer input[1] input 1 int cnt = 0; cnt 0 if(x == 0 && n == 0){
            break;
        }else{
            for(int i = 1; i <= n; i++ ){
            	
                for(int l = i + 1; l <= n; l++ ){
                	
                    for(int k = l + 1; k <= n; k++ ){
                    	//System.out.println(i+"+"+l+"+"+k);
                        if((i + l + k) == x){
                            cnt++;
                        }
                    }
                }
            }
    }//while  x == 0 && n == 0 x == 0 x 0 n == 0 n 0 {
            break;
        } break; {
            for(int i = 1; i <= n; i++ ){
            	
                for(int l = i + 1; l <= n; l++ ){
                	
                    for(int k = l + 1; k <= n; k++ ){
                    	//System.out.println(i+"+"+l+"+"+k);
                        if((i + l + k) == x){
                            cnt++;
                        }
                    }
                }
            }
    } for(int i = 1; i <= n; i++ ){
            	
                for(int l = i + 1; l <= n; l++ ){
                	
                    for(int k = l + 1; k <= n; k++ ){
                    	//System.out.println(i+"+"+l+"+"+k);
                        if((i + l + k) == x){
                            cnt++;
                        }
                    }
                }
            } int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
            	
                for(int l = i + 1; l <= n; l++ ){
                	
                    for(int k = l + 1; k <= n; k++ ){
                    	//System.out.println(i+"+"+l+"+"+k);
                        if((i + l + k) == x){
                            cnt++;
                        }
                    }
                }
            } {
            	
                for(int l = i + 1; l <= n; l++ ){
                	
                    for(int k = l + 1; k <= n; k++ ){
                    	//System.out.println(i+"+"+l+"+"+k);
                        if((i + l + k) == x){
                            cnt++;
                        }
                    }
                }
            } for(int l = i + 1; l <= n; l++ ){
                	
                    for(int k = l + 1; k <= n; k++ ){
                    	//System.out.println(i+"+"+l+"+"+k);
                        if((i + l + k) == x){
                            cnt++;
                        }
                    }
                } int l = i + 1; int l = i + 1; l i + 1 i 1 l <= n l n l++ l++ l {
                	
                    for(int k = l + 1; k <= n; k++ ){
                    	//System.out.println(i+"+"+l+"+"+k);
                        if((i + l + k) == x){
                            cnt++;
                        }
                    }
                } {
                	
                    for(int k = l + 1; k <= n; k++ ){
                    	//System.out.println(i+"+"+l+"+"+k);
                        if((i + l + k) == x){
                            cnt++;
                        }
                    }
                } for(int k = l + 1; k <= n; k++ ){
                    	//System.out.println(i+"+"+l+"+"+k);
                        if((i + l + k) == x){
                            cnt++;
                        }
                    } int k = l + 1; int k = l + 1; k l + 1 l 1 k <= n k n k++ k++ k {
                    	//System.out.println(i+"+"+l+"+"+k);
                        if((i + l + k) == x){
                            cnt++;
                        }
                    } {
                    	//System.out.println(i+"+"+l+"+"+k);
                        if((i + l + k) == x){
                            cnt++;
                        }
                    } if((i + l + k) == x){
                            cnt++;
                        } (i + l + k) == x (i + l + k) i + l + k i l k x {
                            cnt++;
                        } cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt 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[] input = br.readLine().split(" ");
		
		int n = Integer.parseInt(input[0]);
        int x = Integer.parseInt(input[1]);
        int cnt = 0;
        if(x == 0 && n == 0){
            break;
        }else{
            for(int i = 1; i <= n; i++ ){
            	
                for(int l = i + 1; l <= n; l++ ){
                	
                    for(int k = l + 1; k <= n; k++ ){
                    	//System.out.println(i+"+"+l+"+"+k);
                        if((i + l + k) == x){
                            cnt++;
                        }
                    }
                }
            }
    }//while 
        System.out.println(cnt);
		
		}
	}
	
} public class Main {
	public static void main(String[] args) throws IOException{
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
		
		String[] input = br.readLine().split(" ");
		
		int n = Integer.parseInt(input[0]);
        int x = Integer.parseInt(input[1]);
        int cnt = 0;
        if(x == 0 && n == 0){
            break;
        }else{
            for(int i = 1; i <= n; i++ ){
            	
                for(int l = i + 1; l <= n; l++ ){
                	
                    for(int k = l + 1; k <= n; k++ ){
                    	//System.out.println(i+"+"+l+"+"+k);
                        if((i + l + k) == x){
                            cnt++;
                        }
                    }
                }
            }
    }//while 
        System.out.println(cnt);
		
		}
	}
	
} 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[] input = br.readLine().split(" ");
		
		int n = Integer.parseInt(input[0]);
        int x = Integer.parseInt(input[1]);
        int cnt = 0;
        if(x == 0 && n == 0){
            break;
        }else{
            for(int i = 1; i <= n; i++ ){
            	
                for(int l = i + 1; l <= n; l++ ){
                	
                    for(int k = l + 1; k <= n; k++ ){
                    	//System.out.println(i+"+"+l+"+"+k);
                        if((i + l + k) == x){
                            cnt++;
                        }
                    }
                }
            }
    }//while 
        System.out.println(cnt);
		
		}
	}
	
}