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

public class Main{
	public static void main(String[] args)throws IOException{
		int count;
		int add=0;
		int ave3,ave2;
	
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String line = br.readLine();
			String[] str = line.split(" ");
			int n = Integer.parseInt(str[0]);
			int x = Integer.parseInt(str[1]);
			
			if((n == 0) && (x == 0)){
				break;
			}
			
			count = 0;
			ave3 = x / 3;
			for(int i=1; i<ave3; i++){
				ave2 = (x - i) / 2;
				for(int j=i+1; j<=ave2; j++){
					int k = x - i - j;
					if((j < k) && (k <= n)){
						count++;
					}
				}
			}
			System.out.println(count);
		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.IOException; IOException java.io public class Main{
	public static void main(String[] args)throws IOException{
		int count;
		int add=0;
		int ave3,ave2;
	
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String line = br.readLine();
			String[] str = line.split(" ");
			int n = Integer.parseInt(str[0]);
			int x = Integer.parseInt(str[1]);
			
			if((n == 0) && (x == 0)){
				break;
			}
			
			count = 0;
			ave3 = x / 3;
			for(int i=1; i<ave3; i++){
				ave2 = (x - i) / 2;
				for(int j=i+1; j<=ave2; j++){
					int k = x - i - j;
					if((j < k) && (k <= n)){
						count++;
					}
				}
			}
			System.out.println(count);
		}
	}
} Main public static void main(String[] args)throws IOException{
		int count;
		int add=0;
		int ave3,ave2;
	
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String line = br.readLine();
			String[] str = line.split(" ");
			int n = Integer.parseInt(str[0]);
			int x = Integer.parseInt(str[1]);
			
			if((n == 0) && (x == 0)){
				break;
			}
			
			count = 0;
			ave3 = x / 3;
			for(int i=1; i<ave3; i++){
				ave2 = (x - i) / 2;
				for(int j=i+1; j<=ave2; j++){
					int k = x - i - j;
					if((j < k) && (k <= n)){
						count++;
					}
				}
			}
			System.out.println(count);
		}
	} main {
		int count;
		int add=0;
		int ave3,ave2;
	
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String line = br.readLine();
			String[] str = line.split(" ");
			int n = Integer.parseInt(str[0]);
			int x = Integer.parseInt(str[1]);
			
			if((n == 0) && (x == 0)){
				break;
			}
			
			count = 0;
			ave3 = x / 3;
			for(int i=1; i<ave3; i++){
				ave2 = (x - i) / 2;
				for(int j=i+1; j<=ave2; j++){
					int k = x - i - j;
					if((j < k) && (k <= n)){
						count++;
					}
				}
			}
			System.out.println(count);
		}
	} int count; count int add=0; add 0 int ave3 ave3 ave2; ave2 BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true){
			String line = br.readLine();
			String[] str = line.split(" ");
			int n = Integer.parseInt(str[0]);
			int x = Integer.parseInt(str[1]);
			
			if((n == 0) && (x == 0)){
				break;
			}
			
			count = 0;
			ave3 = x / 3;
			for(int i=1; i<ave3; i++){
				ave2 = (x - i) / 2;
				for(int j=i+1; j<=ave2; j++){
					int k = x - i - j;
					if((j < k) && (k <= n)){
						count++;
					}
				}
			}
			System.out.println(count);
		} true {
			String line = br.readLine();
			String[] str = line.split(" ");
			int n = Integer.parseInt(str[0]);
			int x = Integer.parseInt(str[1]);
			
			if((n == 0) && (x == 0)){
				break;
			}
			
			count = 0;
			ave3 = x / 3;
			for(int i=1; i<ave3; i++){
				ave2 = (x - i) / 2;
				for(int j=i+1; j<=ave2; j++){
					int k = x - i - j;
					if((j < k) && (k <= n)){
						count++;
					}
				}
			}
			System.out.println(count);
		} String line = br.readLine(); line br.readLine() br.readLine br String[] str = line.split(" "); str line.split(" ") line.split line " " int n = Integer.parseInt(str[0]); n Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 int x = Integer.parseInt(str[1]); x Integer.parseInt(str[1]) Integer.parseInt Integer str[1] str 1 if((n == 0) && (x == 0)){
				break;
			} (n == 0) && (x == 0) (n == 0) n 0 (x == 0) x 0 {
				break;
			} break; count = 0 count 0 ave3 = x / 3 ave3 x / 3 x 3 for(int i=1; i<ave3; i++){
				ave2 = (x - i) / 2;
				for(int j=i+1; j<=ave2; j++){
					int k = x - i - j;
					if((j < k) && (k <= n)){
						count++;
					}
				}
			} int i=1; int i=1; i 1 i<ave3 i ave3 i++ i++ i {
				ave2 = (x - i) / 2;
				for(int j=i+1; j<=ave2; j++){
					int k = x - i - j;
					if((j < k) && (k <= n)){
						count++;
					}
				}
			} {
				ave2 = (x - i) / 2;
				for(int j=i+1; j<=ave2; j++){
					int k = x - i - j;
					if((j < k) && (k <= n)){
						count++;
					}
				}
			} ave2 = (x - i) / 2 ave2 (x - i) / 2 (x - i) x i 2 for(int j=i+1; j<=ave2; j++){
					int k = x - i - j;
					if((j < k) && (k <= n)){
						count++;
					}
				} int j=i+1; int j=i+1; j i+1 i 1 j<=ave2 j ave2 j++ j++ j {
					int k = x - i - j;
					if((j < k) && (k <= n)){
						count++;
					}
				} {
					int k = x - i - j;
					if((j < k) && (k <= n)){
						count++;
					}
				} int k = x - i - j; k x - i - j x - i - j x i j if((j < k) && (k <= n)){
						count++;
					} (j < k) && (k <= n) (j < k) j k (k <= n) k n {
						count++;
					} count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main{
	public static void main(String[] args)throws IOException{
		int count;
		int add=0;
		int ave3,ave2;
	
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String line = br.readLine();
			String[] str = line.split(" ");
			int n = Integer.parseInt(str[0]);
			int x = Integer.parseInt(str[1]);
			
			if((n == 0) && (x == 0)){
				break;
			}
			
			count = 0;
			ave3 = x / 3;
			for(int i=1; i<ave3; i++){
				ave2 = (x - i) / 2;
				for(int j=i+1; j<=ave2; j++){
					int k = x - i - j;
					if((j < k) && (k <= n)){
						count++;
					}
				}
			}
			System.out.println(count);
		}
	}
} public class Main{
	public static void main(String[] args)throws IOException{
		int count;
		int add=0;
		int ave3,ave2;
	
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String line = br.readLine();
			String[] str = line.split(" ");
			int n = Integer.parseInt(str[0]);
			int x = Integer.parseInt(str[1]);
			
			if((n == 0) && (x == 0)){
				break;
			}
			
			count = 0;
			ave3 = x / 3;
			for(int i=1; i<ave3; i++){
				ave2 = (x - i) / 2;
				for(int j=i+1; j<=ave2; j++){
					int k = x - i - j;
					if((j < k) && (k <= n)){
						count++;
					}
				}
			}
			System.out.println(count);
		}
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{
	public static void main(String[] args)throws IOException{
		int count;
		int add=0;
		int ave3,ave2;
	
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String line = br.readLine();
			String[] str = line.split(" ");
			int n = Integer.parseInt(str[0]);
			int x = Integer.parseInt(str[1]);
			
			if((n == 0) && (x == 0)){
				break;
			}
			
			count = 0;
			ave3 = x / 3;
			for(int i=1; i<ave3; i++){
				ave2 = (x - i) / 2;
				for(int j=i+1; j<=ave2; j++){
					int k = x - i - j;
					if((j < k) && (k <= n)){
						count++;
					}
				}
			}
			System.out.println(count);
		}
	}
}