import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main (String[] args) throws java.lang.Exception
	{
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));
		
		for(;;)
		{
			String[] numberStr = input.readLine().split(" ");
			
			int max = Integer.parseInt(numberStr[0]);
			
			int sum = Integer.parseInt(numberStr[1]);
			
			if((max == 0)&&(sum == 0))
			{
				break;
			}
			
			int set = 0;
			
			for(int oneNum = 1; oneNum <= max - 2; oneNum++)
			{
				for(int twoNum = oneNum + 1; twoNum <= max + 1; twoNum++)
				{
					for(int threeNum = twoNum + 1; threeNum <= max; threeNum++)
					{
						if(oneNum + twoNum + threeNum == sum)
						{
							set++;
						}
					}
				}
			}
			
			System.out.println(set);
		}
	}
}
 import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main (String[] args) throws java.lang.Exception
	{
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));
		
		for(;;)
		{
			String[] numberStr = input.readLine().split(" ");
			
			int max = Integer.parseInt(numberStr[0]);
			
			int sum = Integer.parseInt(numberStr[1]);
			
			if((max == 0)&&(sum == 0))
			{
				break;
			}
			
			int set = 0;
			
			for(int oneNum = 1; oneNum <= max - 2; oneNum++)
			{
				for(int twoNum = oneNum + 1; twoNum <= max + 1; twoNum++)
				{
					for(int threeNum = twoNum + 1; threeNum <= max; threeNum++)
					{
						if(oneNum + twoNum + threeNum == sum)
						{
							set++;
						}
					}
				}
			}
			
			System.out.println(set);
		}
	}
} Main public static void main (String[] args) throws java.lang.Exception
	{
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));
		
		for(;;)
		{
			String[] numberStr = input.readLine().split(" ");
			
			int max = Integer.parseInt(numberStr[0]);
			
			int sum = Integer.parseInt(numberStr[1]);
			
			if((max == 0)&&(sum == 0))
			{
				break;
			}
			
			int set = 0;
			
			for(int oneNum = 1; oneNum <= max - 2; oneNum++)
			{
				for(int twoNum = oneNum + 1; twoNum <= max + 1; twoNum++)
				{
					for(int threeNum = twoNum + 1; threeNum <= max; threeNum++)
					{
						if(oneNum + twoNum + threeNum == sum)
						{
							set++;
						}
					}
				}
			}
			
			System.out.println(set);
		}
	} main {
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));
		
		for(;;)
		{
			String[] numberStr = input.readLine().split(" ");
			
			int max = Integer.parseInt(numberStr[0]);
			
			int sum = Integer.parseInt(numberStr[1]);
			
			if((max == 0)&&(sum == 0))
			{
				break;
			}
			
			int set = 0;
			
			for(int oneNum = 1; oneNum <= max - 2; oneNum++)
			{
				for(int twoNum = oneNum + 1; twoNum <= max + 1; twoNum++)
				{
					for(int threeNum = twoNum + 1; threeNum <= max; threeNum++)
					{
						if(oneNum + twoNum + threeNum == sum)
						{
							set++;
						}
					}
				}
			}
			
			System.out.println(set);
		}
	} BufferedReader input = new BufferedReader (new InputStreamReader (System.in)); input new BufferedReader (new InputStreamReader (System.in)) for(;;)
		{
			String[] numberStr = input.readLine().split(" ");
			
			int max = Integer.parseInt(numberStr[0]);
			
			int sum = Integer.parseInt(numberStr[1]);
			
			if((max == 0)&&(sum == 0))
			{
				break;
			}
			
			int set = 0;
			
			for(int oneNum = 1; oneNum <= max - 2; oneNum++)
			{
				for(int twoNum = oneNum + 1; twoNum <= max + 1; twoNum++)
				{
					for(int threeNum = twoNum + 1; threeNum <= max; threeNum++)
					{
						if(oneNum + twoNum + threeNum == sum)
						{
							set++;
						}
					}
				}
			}
			
			System.out.println(set);
		} ; {
			String[] numberStr = input.readLine().split(" ");
			
			int max = Integer.parseInt(numberStr[0]);
			
			int sum = Integer.parseInt(numberStr[1]);
			
			if((max == 0)&&(sum == 0))
			{
				break;
			}
			
			int set = 0;
			
			for(int oneNum = 1; oneNum <= max - 2; oneNum++)
			{
				for(int twoNum = oneNum + 1; twoNum <= max + 1; twoNum++)
				{
					for(int threeNum = twoNum + 1; threeNum <= max; threeNum++)
					{
						if(oneNum + twoNum + threeNum == sum)
						{
							set++;
						}
					}
				}
			}
			
			System.out.println(set);
		} {
			String[] numberStr = input.readLine().split(" ");
			
			int max = Integer.parseInt(numberStr[0]);
			
			int sum = Integer.parseInt(numberStr[1]);
			
			if((max == 0)&&(sum == 0))
			{
				break;
			}
			
			int set = 0;
			
			for(int oneNum = 1; oneNum <= max - 2; oneNum++)
			{
				for(int twoNum = oneNum + 1; twoNum <= max + 1; twoNum++)
				{
					for(int threeNum = twoNum + 1; threeNum <= max; threeNum++)
					{
						if(oneNum + twoNum + threeNum == sum)
						{
							set++;
						}
					}
				}
			}
			
			System.out.println(set);
		} String[] numberStr = input.readLine().split(" "); numberStr input.readLine().split(" ") input.readLine().split input.readLine() input.readLine input " " int max = Integer.parseInt(numberStr[0]); max Integer.parseInt(numberStr[0]) Integer.parseInt Integer numberStr[0] numberStr 0 int sum = Integer.parseInt(numberStr[1]); sum Integer.parseInt(numberStr[1]) Integer.parseInt Integer numberStr[1] numberStr 1 if((max == 0)&&(sum == 0))
			{
				break;
			} (max == 0)&&(sum == 0) (max == 0) max 0 (sum == 0) sum 0 {
				break;
			} break; int set = 0; set 0 for(int oneNum = 1; oneNum <= max - 2; oneNum++)
			{
				for(int twoNum = oneNum + 1; twoNum <= max + 1; twoNum++)
				{
					for(int threeNum = twoNum + 1; threeNum <= max; threeNum++)
					{
						if(oneNum + twoNum + threeNum == sum)
						{
							set++;
						}
					}
				}
			} int oneNum = 1; int oneNum = 1; oneNum 1 oneNum <= max - 2 oneNum max - 2 max 2 oneNum++ oneNum++ oneNum {
				for(int twoNum = oneNum + 1; twoNum <= max + 1; twoNum++)
				{
					for(int threeNum = twoNum + 1; threeNum <= max; threeNum++)
					{
						if(oneNum + twoNum + threeNum == sum)
						{
							set++;
						}
					}
				}
			} {
				for(int twoNum = oneNum + 1; twoNum <= max + 1; twoNum++)
				{
					for(int threeNum = twoNum + 1; threeNum <= max; threeNum++)
					{
						if(oneNum + twoNum + threeNum == sum)
						{
							set++;
						}
					}
				}
			} for(int twoNum = oneNum + 1; twoNum <= max + 1; twoNum++)
				{
					for(int threeNum = twoNum + 1; threeNum <= max; threeNum++)
					{
						if(oneNum + twoNum + threeNum == sum)
						{
							set++;
						}
					}
				} int twoNum = oneNum + 1; int twoNum = oneNum + 1; twoNum oneNum + 1 oneNum 1 twoNum <= max + 1 twoNum max + 1 max 1 twoNum++ twoNum++ twoNum {
					for(int threeNum = twoNum + 1; threeNum <= max; threeNum++)
					{
						if(oneNum + twoNum + threeNum == sum)
						{
							set++;
						}
					}
				} {
					for(int threeNum = twoNum + 1; threeNum <= max; threeNum++)
					{
						if(oneNum + twoNum + threeNum == sum)
						{
							set++;
						}
					}
				} for(int threeNum = twoNum + 1; threeNum <= max; threeNum++)
					{
						if(oneNum + twoNum + threeNum == sum)
						{
							set++;
						}
					} int threeNum = twoNum + 1; int threeNum = twoNum + 1; threeNum twoNum + 1 twoNum 1 threeNum <= max threeNum max threeNum++ threeNum++ threeNum {
						if(oneNum + twoNum + threeNum == sum)
						{
							set++;
						}
					} {
						if(oneNum + twoNum + threeNum == sum)
						{
							set++;
						}
					} if(oneNum + twoNum + threeNum == sum)
						{
							set++;
						} oneNum + twoNum + threeNum == sum oneNum + twoNum + threeNum oneNum + twoNum + threeNum oneNum twoNum threeNum sum {
							set++;
						} set++ set System.out.println(set) System.out.println System.out System System.out set String[] args args public class Main {
	public static void main (String[] args) throws java.lang.Exception
	{
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));
		
		for(;;)
		{
			String[] numberStr = input.readLine().split(" ");
			
			int max = Integer.parseInt(numberStr[0]);
			
			int sum = Integer.parseInt(numberStr[1]);
			
			if((max == 0)&&(sum == 0))
			{
				break;
			}
			
			int set = 0;
			
			for(int oneNum = 1; oneNum <= max - 2; oneNum++)
			{
				for(int twoNum = oneNum + 1; twoNum <= max + 1; twoNum++)
				{
					for(int threeNum = twoNum + 1; threeNum <= max; threeNum++)
					{
						if(oneNum + twoNum + threeNum == sum)
						{
							set++;
						}
					}
				}
			}
			
			System.out.println(set);
		}
	}
} public class Main {
	public static void main (String[] args) throws java.lang.Exception
	{
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));
		
		for(;;)
		{
			String[] numberStr = input.readLine().split(" ");
			
			int max = Integer.parseInt(numberStr[0]);
			
			int sum = Integer.parseInt(numberStr[1]);
			
			if((max == 0)&&(sum == 0))
			{
				break;
			}
			
			int set = 0;
			
			for(int oneNum = 1; oneNum <= max - 2; oneNum++)
			{
				for(int twoNum = oneNum + 1; twoNum <= max + 1; twoNum++)
				{
					for(int threeNum = twoNum + 1; threeNum <= max; threeNum++)
					{
						if(oneNum + twoNum + threeNum == sum)
						{
							set++;
						}
					}
				}
			}
			
			System.out.println(set);
		}
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main (String[] args) throws java.lang.Exception
	{
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));
		
		for(;;)
		{
			String[] numberStr = input.readLine().split(" ");
			
			int max = Integer.parseInt(numberStr[0]);
			
			int sum = Integer.parseInt(numberStr[1]);
			
			if((max == 0)&&(sum == 0))
			{
				break;
			}
			
			int set = 0;
			
			for(int oneNum = 1; oneNum <= max - 2; oneNum++)
			{
				for(int twoNum = oneNum + 1; twoNum <= max + 1; twoNum++)
				{
					for(int threeNum = twoNum + 1; threeNum <= max; threeNum++)
					{
						if(oneNum + twoNum + threeNum == sum)
						{
							set++;
						}
					}
				}
			}
			
			System.out.println(set);
		}
	}
}

