import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder keepfile = new StringBuilder();
		
        String[] str;

		while(true) {
	//??\???????????????????????????
		str = br.readLine().split(" ");	
		int n = Integer.parseInt(str[0]);
		int x = Integer.parseInt(str[1]);;
		if(n == 0 & x == 0) break;
		
	//?¨???????????????????????????????	 
		else if(n != 0 & x != 0 | n >= 3 & n <= 100 | x >= 0 & x <= 300) {
			int N = 0 ;         //N ???????¨????x??¨????????????????????????????????°??§???
			for(int i = 1; i <= n ; i++) {
			   for(int j = (i+1) ; j <= n ; j++) {
				   int k = 0 ;
					   k = x-i-j ;         //x = i+j+k ???????????????k=x-i-j ??¨?????????
					   if(j < k & k <= n) N++; 
			  }
			   
		   }
			 keepfile.append(N).append("\n");
		}
		
	  }
		
	//??????????????????????????????
		   System.out.print(keepfile);
	
	   br.close();
	}

}
/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz