import java.util.Scanner;
import java.util.Arrays;

class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		
		while(true){
			int n = scanner.nextInt();
			int x = scanner.nextInt();
			int count = 0;

			if(n == 0 && x == 0){
				break;
			}

			for(int i = 1; i < x/3; i++){
				for(int j = i+1; j < n; j++){
					int k = x - i - j;
					if(k > j && k <= n){
					    count ++;
					}
				}
			}
			System.out.println(count);
		}
	}

} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		
		while(true){
			int n = scanner.nextInt();
			int x = scanner.nextInt();
			int count = 0;

			if(n == 0 && x == 0){
				break;
			}

			for(int i = 1; i < x/3; i++){
				for(int j = i+1; j < n; j++){
					int k = x - i - j;
					if(k > j && k <= n){
					    count ++;
					}
				}
			}
			System.out.println(count);
		}
	}

} Main public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		
		while(true){
			int n = scanner.nextInt();
			int x = scanner.nextInt();
			int count = 0;

			if(n == 0 && x == 0){
				break;
			}

			for(int i = 1; i < x/3; i++){
				for(int j = i+1; j < n; j++){
					int k = x - i - j;
					if(k > j && k <= n){
					    count ++;
					}
				}
			}
			System.out.println(count);
		}
	} main {
		Scanner scanner = new Scanner(System.in);
		
		while(true){
			int n = scanner.nextInt();
			int x = scanner.nextInt();
			int count = 0;

			if(n == 0 && x == 0){
				break;
			}

			for(int i = 1; i < x/3; i++){
				for(int j = i+1; j < n; j++){
					int k = x - i - j;
					if(k > j && k <= n){
					    count ++;
					}
				}
			}
			System.out.println(count);
		}
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) while(true){
			int n = scanner.nextInt();
			int x = scanner.nextInt();
			int count = 0;

			if(n == 0 && x == 0){
				break;
			}

			for(int i = 1; i < x/3; i++){
				for(int j = i+1; j < n; j++){
					int k = x - i - j;
					if(k > j && k <= n){
					    count ++;
					}
				}
			}
			System.out.println(count);
		} true {
			int n = scanner.nextInt();
			int x = scanner.nextInt();
			int count = 0;

			if(n == 0 && x == 0){
				break;
			}

			for(int i = 1; i < x/3; i++){
				for(int j = i+1; j < n; j++){
					int k = x - i - j;
					if(k > j && k <= n){
					    count ++;
					}
				}
			}
			System.out.println(count);
		} int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner int x = scanner.nextInt(); x scanner.nextInt() scanner.nextInt scanner int count = 0; count 0 if(n == 0 && x == 0){
				break;
			} n == 0 && x == 0 n == 0 n 0 x == 0 x 0 {
				break;
			} break; for(int i = 1; i < x/3; i++){
				for(int j = i+1; j < n; j++){
					int k = x - i - j;
					if(k > j && k <= n){
					    count ++;
					}
				}
			} int i = 1; int i = 1; i 1 i < x/3 i x/3 x 3 i++ i++ i {
				for(int j = i+1; j < n; j++){
					int k = x - i - j;
					if(k > j && k <= n){
					    count ++;
					}
				}
			} {
				for(int j = i+1; j < n; j++){
					int k = x - i - j;
					if(k > j && k <= n){
					    count ++;
					}
				}
			} for(int j = i+1; j < n; j++){
					int k = x - i - j;
					if(k > j && k <= n){
					    count ++;
					}
				} int j = i+1; int j = i+1; j i+1 i 1 j < n j n j++ j++ j {
					int k = x - i - j;
					if(k > j && k <= n){
					    count ++;
					}
				} {
					int k = x - i - j;
					if(k > j && k <= n){
					    count ++;
					}
				} int k = x - i - j; k x - i - j x - i - j x i j if(k > j && k <= n){
					    count ++;
					} k > j && k <= n k > j k j k <= n k n {
					    count ++;
					} count ++ count System.out.println(count) System.out.println System.out System System.out count String[] args args
import java.util.Scanner;
import java.util.Arrays;

class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		
		while(true){
			int n = scanner.nextInt();
			int x = scanner.nextInt();
			int count = 0;

			if(n == 0 && x == 0){
				break;
			}

			for(int i = 1; i < x/3; i++){
				for(int j = i+1; j < n; j++){
					int k = x - i - j;
					if(k > j && k <= n){
					    count ++;
					}
				}
			}
			System.out.println(count);
		}
	}

}