import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		
		while(true) {
			int n = scan.nextInt();
			int x = scan.nextInt();
			
			if(n == 0) break;
			int count = 0;
			for(int i = 1; i <= n - 2; i++) {
				for(int j = i + 1; j <= n - 1; j++) {
					int check_number = x - i - j;
					if(check_number <= n && check_number > j) {
						count++;
					}
				}
			}
			System.out.println(count);
		}
		
	}

}
 import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		
		while(true) {
			int n = scan.nextInt();
			int x = scan.nextInt();
			
			if(n == 0) break;
			int count = 0;
			for(int i = 1; i <= n - 2; i++) {
				for(int j = i + 1; j <= n - 1; j++) {
					int check_number = x - i - j;
					if(check_number <= n && check_number > j) {
						count++;
					}
				}
			}
			System.out.println(count);
		}
		
	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		
		while(true) {
			int n = scan.nextInt();
			int x = scan.nextInt();
			
			if(n == 0) break;
			int count = 0;
			for(int i = 1; i <= n - 2; i++) {
				for(int j = i + 1; j <= n - 1; j++) {
					int check_number = x - i - j;
					if(check_number <= n && check_number > j) {
						count++;
					}
				}
			}
			System.out.println(count);
		}
		
	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		
		while(true) {
			int n = scan.nextInt();
			int x = scan.nextInt();
			
			if(n == 0) break;
			int count = 0;
			for(int i = 1; i <= n - 2; i++) {
				for(int j = i + 1; j <= n - 1; j++) {
					int check_number = x - i - j;
					if(check_number <= n && check_number > j) {
						count++;
					}
				}
			}
			System.out.println(count);
		}
		
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) while(true) {
			int n = scan.nextInt();
			int x = scan.nextInt();
			
			if(n == 0) break;
			int count = 0;
			for(int i = 1; i <= n - 2; i++) {
				for(int j = i + 1; j <= n - 1; j++) {
					int check_number = x - i - j;
					if(check_number <= n && check_number > j) {
						count++;
					}
				}
			}
			System.out.println(count);
		} true {
			int n = scan.nextInt();
			int x = scan.nextInt();
			
			if(n == 0) break;
			int count = 0;
			for(int i = 1; i <= n - 2; i++) {
				for(int j = i + 1; j <= n - 1; j++) {
					int check_number = x - i - j;
					if(check_number <= n && check_number > j) {
						count++;
					}
				}
			}
			System.out.println(count);
		} int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int x = scan.nextInt(); x scan.nextInt() scan.nextInt scan if(n == 0) break; n == 0 n 0 break; int count = 0; count 0 for(int i = 1; i <= n - 2; i++) {
				for(int j = i + 1; j <= n - 1; j++) {
					int check_number = x - i - j;
					if(check_number <= n && check_number > j) {
						count++;
					}
				}
			} int i = 1; int i = 1; i 1 i <= n - 2 i n - 2 n 2 i++ i++ i {
				for(int j = i + 1; j <= n - 1; j++) {
					int check_number = x - i - j;
					if(check_number <= n && check_number > j) {
						count++;
					}
				}
			} {
				for(int j = i + 1; j <= n - 1; j++) {
					int check_number = x - i - j;
					if(check_number <= n && check_number > j) {
						count++;
					}
				}
			} for(int j = i + 1; j <= n - 1; j++) {
					int check_number = x - i - j;
					if(check_number <= n && check_number > j) {
						count++;
					}
				} int j = i + 1; int j = i + 1; j i + 1 i 1 j <= n - 1 j n - 1 n 1 j++ j++ j {
					int check_number = x - i - j;
					if(check_number <= n && check_number > j) {
						count++;
					}
				} {
					int check_number = x - i - j;
					if(check_number <= n && check_number > j) {
						count++;
					}
				} int check_number = x - i - j; check_number x - i - j x - i - j x i j if(check_number <= n && check_number > j) {
						count++;
					} check_number <= n && check_number > j check_number <= n check_number n check_number > j check_number j {
						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) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		
		while(true) {
			int n = scan.nextInt();
			int x = scan.nextInt();
			
			if(n == 0) break;
			int count = 0;
			for(int i = 1; i <= n - 2; i++) {
				for(int j = i + 1; j <= n - 1; j++) {
					int check_number = x - i - j;
					if(check_number <= n && check_number > j) {
						count++;
					}
				}
			}
			System.out.println(count);
		}
		
	}

} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		
		while(true) {
			int n = scan.nextInt();
			int x = scan.nextInt();
			
			if(n == 0) break;
			int count = 0;
			for(int i = 1; i <= n - 2; i++) {
				for(int j = i + 1; j <= n - 1; j++) {
					int check_number = x - i - j;
					if(check_number <= n && check_number > j) {
						count++;
					}
				}
			}
			System.out.println(count);
		}
		
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		
		while(true) {
			int n = scan.nextInt();
			int x = scan.nextInt();
			
			if(n == 0) break;
			int count = 0;
			for(int i = 1; i <= n - 2; i++) {
				for(int j = i + 1; j <= n - 1; j++) {
					int check_number = x - i - j;
					if(check_number <= n && check_number > j) {
						count++;
					}
				}
			}
			System.out.println(count);
		}
		
	}

}

