import java.util.Scanner;

class Main{
    public static void main(String[] args){
    	int n,x,max;
    	int count = 0;
    	Scanner sc = new Scanner(System.in);
    	while(true){
    		n = sc.nextInt();
        	x = sc.nextInt();
        	if(n ==0 && x ==0){
        		break;
        	}
        	max = n >= x ? x:n;

        	for(int i = 1; i <= max-2 ;i++){
        		for(int j = i+1; j <= max-1 ;j++){
        			for(int k = j+1; k <= max ;k++){
        				if(i+j+k == x){
        					count++;
        					break;
        				}
        			}
        		}
        	}
            System.out.println(count);
            count = 0;
    	}

    }
} import java.util.Scanner; Scanner java.util class Main{
    public static void main(String[] args){
    	int n,x,max;
    	int count = 0;
    	Scanner sc = new Scanner(System.in);
    	while(true){
    		n = sc.nextInt();
        	x = sc.nextInt();
        	if(n ==0 && x ==0){
        		break;
        	}
        	max = n >= x ? x:n;

        	for(int i = 1; i <= max-2 ;i++){
        		for(int j = i+1; j <= max-1 ;j++){
        			for(int k = j+1; k <= max ;k++){
        				if(i+j+k == x){
        					count++;
        					break;
        				}
        			}
        		}
        	}
            System.out.println(count);
            count = 0;
    	}

    }
} Main public static void main(String[] args){
    	int n,x,max;
    	int count = 0;
    	Scanner sc = new Scanner(System.in);
    	while(true){
    		n = sc.nextInt();
        	x = sc.nextInt();
        	if(n ==0 && x ==0){
        		break;
        	}
        	max = n >= x ? x:n;

        	for(int i = 1; i <= max-2 ;i++){
        		for(int j = i+1; j <= max-1 ;j++){
        			for(int k = j+1; k <= max ;k++){
        				if(i+j+k == x){
        					count++;
        					break;
        				}
        			}
        		}
        	}
            System.out.println(count);
            count = 0;
    	}

    } main {
    	int n,x,max;
    	int count = 0;
    	Scanner sc = new Scanner(System.in);
    	while(true){
    		n = sc.nextInt();
        	x = sc.nextInt();
        	if(n ==0 && x ==0){
        		break;
        	}
        	max = n >= x ? x:n;

        	for(int i = 1; i <= max-2 ;i++){
        		for(int j = i+1; j <= max-1 ;j++){
        			for(int k = j+1; k <= max ;k++){
        				if(i+j+k == x){
        					count++;
        					break;
        				}
        			}
        		}
        	}
            System.out.println(count);
            count = 0;
    	}

    } int n n x x max; max int count = 0; count 0 Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true){
    		n = sc.nextInt();
        	x = sc.nextInt();
        	if(n ==0 && x ==0){
        		break;
        	}
        	max = n >= x ? x:n;

        	for(int i = 1; i <= max-2 ;i++){
        		for(int j = i+1; j <= max-1 ;j++){
        			for(int k = j+1; k <= max ;k++){
        				if(i+j+k == x){
        					count++;
        					break;
        				}
        			}
        		}
        	}
            System.out.println(count);
            count = 0;
    	} true {
    		n = sc.nextInt();
        	x = sc.nextInt();
        	if(n ==0 && x ==0){
        		break;
        	}
        	max = n >= x ? x:n;

        	for(int i = 1; i <= max-2 ;i++){
        		for(int j = i+1; j <= max-1 ;j++){
        			for(int k = j+1; k <= max ;k++){
        				if(i+j+k == x){
        					count++;
        					break;
        				}
        			}
        		}
        	}
            System.out.println(count);
            count = 0;
    	} n = sc.nextInt() n sc.nextInt() sc.nextInt sc x = sc.nextInt() x sc.nextInt() sc.nextInt sc if(n ==0 && x ==0){
        		break;
        	} n ==0 && x ==0 n ==0 n 0 x ==0 x 0 {
        		break;
        	} break; max = n >= x ? x:n max n >= x ? x:n n >= x n x x n for(int i = 1; i <= max-2 ;i++){
        		for(int j = i+1; j <= max-1 ;j++){
        			for(int k = j+1; k <= max ;k++){
        				if(i+j+k == x){
        					count++;
        					break;
        				}
        			}
        		}
        	} int i = 1; int i = 1; i 1 i <= max-2 i max-2 max 2 i++ i++ i {
        		for(int j = i+1; j <= max-1 ;j++){
        			for(int k = j+1; k <= max ;k++){
        				if(i+j+k == x){
        					count++;
        					break;
        				}
        			}
        		}
        	} {
        		for(int j = i+1; j <= max-1 ;j++){
        			for(int k = j+1; k <= max ;k++){
        				if(i+j+k == x){
        					count++;
        					break;
        				}
        			}
        		}
        	} for(int j = i+1; j <= max-1 ;j++){
        			for(int k = j+1; k <= max ;k++){
        				if(i+j+k == x){
        					count++;
        					break;
        				}
        			}
        		} int j = i+1; int j = i+1; j i+1 i 1 j <= max-1 j max-1 max 1 j++ j++ j {
        			for(int k = j+1; k <= max ;k++){
        				if(i+j+k == x){
        					count++;
        					break;
        				}
        			}
        		} {
        			for(int k = j+1; k <= max ;k++){
        				if(i+j+k == x){
        					count++;
        					break;
        				}
        			}
        		} for(int k = j+1; k <= max ;k++){
        				if(i+j+k == x){
        					count++;
        					break;
        				}
        			} int k = j+1; int k = j+1; k j+1 j 1 k <= max k max k++ k++ k {
        				if(i+j+k == x){
        					count++;
        					break;
        				}
        			} {
        				if(i+j+k == x){
        					count++;
        					break;
        				}
        			} if(i+j+k == x){
        					count++;
        					break;
        				} i+j+k == x i+j+k i+j+k i j k x {
        					count++;
        					break;
        				} count++ count break; System.out.println(count) System.out.println System.out System System.out count count = 0 count 0 String[] args args
import java.util.Scanner;

class Main{
    public static void main(String[] args){
    	int n,x,max;
    	int count = 0;
    	Scanner sc = new Scanner(System.in);
    	while(true){
    		n = sc.nextInt();
        	x = sc.nextInt();
        	if(n ==0 && x ==0){
        		break;
        	}
        	max = n >= x ? x:n;

        	for(int i = 1; i <= max-2 ;i++){
        		for(int j = i+1; j <= max-1 ;j++){
        			for(int k = j+1; k <= max ;k++){
        				if(i+j+k == x){
        					count++;
        					break;
        				}
        			}
        		}
        	}
            System.out.println(count);
            count = 0;
    	}

    }
}