import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Main test = new Main();
		test.run();
	}
	
	void run(){
		final BufferedReader  in = new BufferedReader(new InputStreamReader(System.in));
		
		do {
			int[] indata = null;
			try{
				indata = changeData(in.readLine());
			}catch(IOException e){
			}
			
			if(!checkData(indata))break;
		}while(true);		
	}
	
	int[] changeData(String data){
		String[] elem = data.split(" ");
		int[] datas = new int[elem.length];
		for (int i = 0; i < elem.length; i++){
			datas[i] = Integer.parseInt(elem[i]);
		}
		return datas;
	}
	boolean checkData(int[] data){
		if (data[0]==0 && data[1]==0) return false;
		System.out.println(countData(data[0],data[1]));
		return true;
	}
	
	int countData(int a, int b){
		int count=0;
		for(int i=1; i<=a; i++)
			for(int j=i+1; j<=a; j++)
				for(int k=j+1; k<=a; k++)
					if (i+j+k == b)count ++;
		return count;
	}
} import java.io.*; io.* java import java.util.*; util.* java public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Main test = new Main();
		test.run();
	}
	
	void run(){
		final BufferedReader  in = new BufferedReader(new InputStreamReader(System.in));
		
		do {
			int[] indata = null;
			try{
				indata = changeData(in.readLine());
			}catch(IOException e){
			}
			
			if(!checkData(indata))break;
		}while(true);		
	}
	
	int[] changeData(String data){
		String[] elem = data.split(" ");
		int[] datas = new int[elem.length];
		for (int i = 0; i < elem.length; i++){
			datas[i] = Integer.parseInt(elem[i]);
		}
		return datas;
	}
	boolean checkData(int[] data){
		if (data[0]==0 && data[1]==0) return false;
		System.out.println(countData(data[0],data[1]));
		return true;
	}
	
	int countData(int a, int b){
		int count=0;
		for(int i=1; i<=a; i++)
			for(int j=i+1; j<=a; j++)
				for(int k=j+1; k<=a; k++)
					if (i+j+k == b)count ++;
		return count;
	}
} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		Main test = new Main();
		test.run();
	} main {
		// TODO Auto-generated method stub
		Main test = new Main();
		test.run();
	} Main test = new Main(); test new Main() test.run() test.run test String[] args args void run(){
		final BufferedReader  in = new BufferedReader(new InputStreamReader(System.in));
		
		do {
			int[] indata = null;
			try{
				indata = changeData(in.readLine());
			}catch(IOException e){
			}
			
			if(!checkData(indata))break;
		}while(true);		
	} run {
		final BufferedReader  in = new BufferedReader(new InputStreamReader(System.in));
		
		do {
			int[] indata = null;
			try{
				indata = changeData(in.readLine());
			}catch(IOException e){
			}
			
			if(!checkData(indata))break;
		}while(true);		
	} final BufferedReader  in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) do {
			int[] indata = null;
			try{
				indata = changeData(in.readLine());
			}catch(IOException e){
			}
			
			if(!checkData(indata))break;
		}while(true); true {
			int[] indata = null;
			try{
				indata = changeData(in.readLine());
			}catch(IOException e){
			}
			
			if(!checkData(indata))break;
		} int[] indata = null; indata null try{
				indata = changeData(in.readLine());
			}catch(IOException e){
			} catch(IOException e){
			} IOException e {
			} {
				indata = changeData(in.readLine());
			} indata = changeData(in.readLine()) indata changeData(in.readLine()) changeData in.readLine() in.readLine in if(!checkData(indata))break; !checkData(indata) checkData(indata) checkData indata break; int[] changeData(String data){
		String[] elem = data.split(" ");
		int[] datas = new int[elem.length];
		for (int i = 0; i < elem.length; i++){
			datas[i] = Integer.parseInt(elem[i]);
		}
		return datas;
	} changeData {
		String[] elem = data.split(" ");
		int[] datas = new int[elem.length];
		for (int i = 0; i < elem.length; i++){
			datas[i] = Integer.parseInt(elem[i]);
		}
		return datas;
	} String[] elem = data.split(" "); elem data.split(" ") data.split data " " int[] datas = new int[elem.length]; datas new int[elem.length] elem.length elem elem.length for (int i = 0; i < elem.length; i++){
			datas[i] = Integer.parseInt(elem[i]);
		} int i = 0; int i = 0; i 0 i < elem.length i elem.length elem elem.length i++ i++ i {
			datas[i] = Integer.parseInt(elem[i]);
		} {
			datas[i] = Integer.parseInt(elem[i]);
		} datas[i] = Integer.parseInt(elem[i]) datas[i] datas i Integer.parseInt(elem[i]) Integer.parseInt Integer elem[i] elem i return datas; datas String data data boolean checkData(int[] data){
		if (data[0]==0 && data[1]==0) return false;
		System.out.println(countData(data[0],data[1]));
		return true;
	} checkData {
		if (data[0]==0 && data[1]==0) return false;
		System.out.println(countData(data[0],data[1]));
		return true;
	} if (data[0]==0 && data[1]==0) return false; data[0]==0 && data[1]==0 data[0]==0 data[0] data 0 0 data[1]==0 data[1] data 1 0 return false; false System.out.println(countData(data[0],data[1])) System.out.println System.out System System.out countData(data[0],data[1]) countData data[0] data 0 data[1] data 1 return true; true int[] data data int countData(int a, int b){
		int count=0;
		for(int i=1; i<=a; i++)
			for(int j=i+1; j<=a; j++)
				for(int k=j+1; k<=a; k++)
					if (i+j+k == b)count ++;
		return count;
	} countData {
		int count=0;
		for(int i=1; i<=a; i++)
			for(int j=i+1; j<=a; j++)
				for(int k=j+1; k<=a; k++)
					if (i+j+k == b)count ++;
		return count;
	} int count=0; count 0 for(int i=1; i<=a; i++)
			for(int j=i+1; j<=a; j++)
				for(int k=j+1; k<=a; k++)
					if (i+j+k == b)count ++; int i=1; int i=1; i 1 i<=a i a i++ i++ i for(int j=i+1; j<=a; j++)
				for(int k=j+1; k<=a; k++)
					if (i+j+k == b)count ++; for(int j=i+1; j<=a; j++)
				for(int k=j+1; k<=a; k++)
					if (i+j+k == b)count ++; int j=i+1; int j=i+1; j i+1 i 1 j<=a j a j++ j++ j for(int k=j+1; k<=a; k++)
					if (i+j+k == b)count ++; for(int k=j+1; k<=a; k++)
					if (i+j+k == b)count ++; int k=j+1; int k=j+1; k j+1 j 1 k<=a k a k++ k++ k if (i+j+k == b)count ++; if (i+j+k == b)count ++; i+j+k == b i+j+k i+j+k i j k b count ++ count return count; count int a a int b b public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Main test = new Main();
		test.run();
	}
	
	void run(){
		final BufferedReader  in = new BufferedReader(new InputStreamReader(System.in));
		
		do {
			int[] indata = null;
			try{
				indata = changeData(in.readLine());
			}catch(IOException e){
			}
			
			if(!checkData(indata))break;
		}while(true);		
	}
	
	int[] changeData(String data){
		String[] elem = data.split(" ");
		int[] datas = new int[elem.length];
		for (int i = 0; i < elem.length; i++){
			datas[i] = Integer.parseInt(elem[i]);
		}
		return datas;
	}
	boolean checkData(int[] data){
		if (data[0]==0 && data[1]==0) return false;
		System.out.println(countData(data[0],data[1]));
		return true;
	}
	
	int countData(int a, int b){
		int count=0;
		for(int i=1; i<=a; i++)
			for(int j=i+1; j<=a; j++)
				for(int k=j+1; k<=a; k++)
					if (i+j+k == b)count ++;
		return count;
	}
} public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Main test = new Main();
		test.run();
	}
	
	void run(){
		final BufferedReader  in = new BufferedReader(new InputStreamReader(System.in));
		
		do {
			int[] indata = null;
			try{
				indata = changeData(in.readLine());
			}catch(IOException e){
			}
			
			if(!checkData(indata))break;
		}while(true);		
	}
	
	int[] changeData(String data){
		String[] elem = data.split(" ");
		int[] datas = new int[elem.length];
		for (int i = 0; i < elem.length; i++){
			datas[i] = Integer.parseInt(elem[i]);
		}
		return datas;
	}
	boolean checkData(int[] data){
		if (data[0]==0 && data[1]==0) return false;
		System.out.println(countData(data[0],data[1]));
		return true;
	}
	
	int countData(int a, int b){
		int count=0;
		for(int i=1; i<=a; i++)
			for(int j=i+1; j<=a; j++)
				for(int k=j+1; k<=a; k++)
					if (i+j+k == b)count ++;
		return count;
	}
} Main
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Main test = new Main();
		test.run();
	}
	
	void run(){
		final BufferedReader  in = new BufferedReader(new InputStreamReader(System.in));
		
		do {
			int[] indata = null;
			try{
				indata = changeData(in.readLine());
			}catch(IOException e){
			}
			
			if(!checkData(indata))break;
		}while(true);		
	}
	
	int[] changeData(String data){
		String[] elem = data.split(" ");
		int[] datas = new int[elem.length];
		for (int i = 0; i < elem.length; i++){
			datas[i] = Integer.parseInt(elem[i]);
		}
		return datas;
	}
	boolean checkData(int[] data){
		if (data[0]==0 && data[1]==0) return false;
		System.out.println(countData(data[0],data[1]));
		return true;
	}
	
	int countData(int a, int b){
		int count=0;
		for(int i=1; i<=a; i++)
			for(int j=i+1; j<=a; j++)
				for(int k=j+1; k<=a; k++)
					if (i+j+k == b)count ++;
		return count;
	}
}