import java.util.Scanner;

class Main{
      public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	int n;
    	int x;
    	int total = 0;
    	int count = 0;
    	int c = 3 * 2 * 1; //3?????????????????????????????????????????????
    	int end = 0;
    	
    	for(;;){
    		n = scan.nextInt();
    		x = scan.nextInt();
    		
    		if(n == end && x == end){
    			break;
    		}
    		
    		for(int i = 1; i <= n; i++){
    			for(int j = 1; j <= n; j++){
    				for(int k = 1; k <= n; k++){
    					if(i != j && j != k && k != i){
	    					total = i + j + k;
	    	    			if(x == total) count++;
    					}
    	    		}
        		}
    		}
    		System.out.println(count / c);
    		count = 0;
    	}
    }
} import java.util.Scanner; Scanner java.util class Main{
      public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	int n;
    	int x;
    	int total = 0;
    	int count = 0;
    	int c = 3 * 2 * 1; //3?????????????????????????????????????????????
    	int end = 0;
    	
    	for(;;){
    		n = scan.nextInt();
    		x = scan.nextInt();
    		
    		if(n == end && x == end){
    			break;
    		}
    		
    		for(int i = 1; i <= n; i++){
    			for(int j = 1; j <= n; j++){
    				for(int k = 1; k <= n; k++){
    					if(i != j && j != k && k != i){
	    					total = i + j + k;
	    	    			if(x == total) count++;
    					}
    	    		}
        		}
    		}
    		System.out.println(count / c);
    		count = 0;
    	}
    }
} Main public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	int n;
    	int x;
    	int total = 0;
    	int count = 0;
    	int c = 3 * 2 * 1; //3?????????????????????????????????????????????
    	int end = 0;
    	
    	for(;;){
    		n = scan.nextInt();
    		x = scan.nextInt();
    		
    		if(n == end && x == end){
    			break;
    		}
    		
    		for(int i = 1; i <= n; i++){
    			for(int j = 1; j <= n; j++){
    				for(int k = 1; k <= n; k++){
    					if(i != j && j != k && k != i){
	    					total = i + j + k;
	    	    			if(x == total) count++;
    					}
    	    		}
        		}
    		}
    		System.out.println(count / c);
    		count = 0;
    	}
    } main {
    	Scanner scan = new Scanner(System.in);
    	int n;
    	int x;
    	int total = 0;
    	int count = 0;
    	int c = 3 * 2 * 1; //3?????????????????????????????????????????????
    	int end = 0;
    	
    	for(;;){
    		n = scan.nextInt();
    		x = scan.nextInt();
    		
    		if(n == end && x == end){
    			break;
    		}
    		
    		for(int i = 1; i <= n; i++){
    			for(int j = 1; j <= n; j++){
    				for(int k = 1; k <= n; k++){
    					if(i != j && j != k && k != i){
	    					total = i + j + k;
	    	    			if(x == total) count++;
    					}
    	    		}
        		}
    		}
    		System.out.println(count / c);
    		count = 0;
    	}
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n; n int x; x int total = 0; total 0 int count = 0; count 0 int c = 3 * 2 * 1; c 3 * 2 * 1 3 * 2 * 1 3 2 1 int end = 0; end 0 for(;;){
    		n = scan.nextInt();
    		x = scan.nextInt();
    		
    		if(n == end && x == end){
    			break;
    		}
    		
    		for(int i = 1; i <= n; i++){
    			for(int j = 1; j <= n; j++){
    				for(int k = 1; k <= n; k++){
    					if(i != j && j != k && k != i){
	    					total = i + j + k;
	    	    			if(x == total) count++;
    					}
    	    		}
        		}
    		}
    		System.out.println(count / c);
    		count = 0;
    	} ; {
    		n = scan.nextInt();
    		x = scan.nextInt();
    		
    		if(n == end && x == end){
    			break;
    		}
    		
    		for(int i = 1; i <= n; i++){
    			for(int j = 1; j <= n; j++){
    				for(int k = 1; k <= n; k++){
    					if(i != j && j != k && k != i){
	    					total = i + j + k;
	    	    			if(x == total) count++;
    					}
    	    		}
        		}
    		}
    		System.out.println(count / c);
    		count = 0;
    	} {
    		n = scan.nextInt();
    		x = scan.nextInt();
    		
    		if(n == end && x == end){
    			break;
    		}
    		
    		for(int i = 1; i <= n; i++){
    			for(int j = 1; j <= n; j++){
    				for(int k = 1; k <= n; k++){
    					if(i != j && j != k && k != i){
	    					total = i + j + k;
	    	    			if(x == total) count++;
    					}
    	    		}
        		}
    		}
    		System.out.println(count / c);
    		count = 0;
    	} n = scan.nextInt() n scan.nextInt() scan.nextInt scan x = scan.nextInt() x scan.nextInt() scan.nextInt scan if(n == end && x == end){
    			break;
    		} n == end && x == end n == end n end x == end x end {
    			break;
    		} break; for(int i = 1; i <= n; i++){
    			for(int j = 1; j <= n; j++){
    				for(int k = 1; k <= n; k++){
    					if(i != j && j != k && k != i){
	    					total = i + j + k;
	    	    			if(x == total) count++;
    					}
    	    		}
        		}
    		} int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
    			for(int j = 1; j <= n; j++){
    				for(int k = 1; k <= n; k++){
    					if(i != j && j != k && k != i){
	    					total = i + j + k;
	    	    			if(x == total) count++;
    					}
    	    		}
        		}
    		} {
    			for(int j = 1; j <= n; j++){
    				for(int k = 1; k <= n; k++){
    					if(i != j && j != k && k != i){
	    					total = i + j + k;
	    	    			if(x == total) count++;
    					}
    	    		}
        		}
    		} for(int j = 1; j <= n; j++){
    				for(int k = 1; k <= n; k++){
    					if(i != j && j != k && k != i){
	    					total = i + j + k;
	    	    			if(x == total) count++;
    					}
    	    		}
        		} int j = 1; int j = 1; j 1 j <= n j n j++ j++ j {
    				for(int k = 1; k <= n; k++){
    					if(i != j && j != k && k != i){
	    					total = i + j + k;
	    	    			if(x == total) count++;
    					}
    	    		}
        		} {
    				for(int k = 1; k <= n; k++){
    					if(i != j && j != k && k != i){
	    					total = i + j + k;
	    	    			if(x == total) count++;
    					}
    	    		}
        		} for(int k = 1; k <= n; k++){
    					if(i != j && j != k && k != i){
	    					total = i + j + k;
	    	    			if(x == total) count++;
    					}
    	    		} int k = 1; int k = 1; k 1 k <= n k n k++ k++ k {
    					if(i != j && j != k && k != i){
	    					total = i + j + k;
	    	    			if(x == total) count++;
    					}
    	    		} {
    					if(i != j && j != k && k != i){
	    					total = i + j + k;
	    	    			if(x == total) count++;
    					}
    	    		} if(i != j && j != k && k != i){
	    					total = i + j + k;
	    	    			if(x == total) count++;
    					} i != j && j != k && k != i i != j && j != k && k != i i != j i j j != k j k k != i k i {
	    					total = i + j + k;
	    	    			if(x == total) count++;
    					} total = i + j + k total i + j + k i + j + k i j k if(x == total) count++; x == total x total count++ count System.out.println(count / c) System.out.println System.out System System.out count / c count c count = 0 count 0 String[] args args
import java.util.Scanner;

class Main{
      public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	int n;
    	int x;
    	int total = 0;
    	int count = 0;
    	int c = 3 * 2 * 1; //3?????????????????????????????????????????????
    	int end = 0;
    	
    	for(;;){
    		n = scan.nextInt();
    		x = scan.nextInt();
    		
    		if(n == end && x == end){
    			break;
    		}
    		
    		for(int i = 1; i <= n; i++){
    			for(int j = 1; j <= n; j++){
    				for(int k = 1; k <= n; k++){
    					if(i != j && j != k && k != i){
	    					total = i + j + k;
	    	    			if(x == total) count++;
    					}
    	    		}
        		}
    		}
    		System.out.println(count / c);
    		count = 0;
    	}
    }
}