import java.util.Scanner;
public class Main {
	void hmw(){
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int x = s.nextInt();
		while(n != 0||x != 0){
			int cnt = 0;
			for(int i = 1;i <= n - 2;i++){
				for(int j = i + 1;j <= n - 1 && (i+j)*3 < x*2 ;j++){
					int k = x - (i + j);
					if(k <= n && k > j){
//System.out.println("#"+i + ":" + j + ":" + k);
						cnt++;
					}
				}
			}
			System.out.println(cnt);
			n = s.nextInt();
			x = s.nextInt();
		}
	}
	public static void main(String args[]){
		Main m = new Main();
		m.hmw();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	void hmw(){
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int x = s.nextInt();
		while(n != 0||x != 0){
			int cnt = 0;
			for(int i = 1;i <= n - 2;i++){
				for(int j = i + 1;j <= n - 1 && (i+j)*3 < x*2 ;j++){
					int k = x - (i + j);
					if(k <= n && k > j){
//System.out.println("#"+i + ":" + j + ":" + k);
						cnt++;
					}
				}
			}
			System.out.println(cnt);
			n = s.nextInt();
			x = s.nextInt();
		}
	}
	public static void main(String args[]){
		Main m = new Main();
		m.hmw();
	}
} Main void hmw(){
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int x = s.nextInt();
		while(n != 0||x != 0){
			int cnt = 0;
			for(int i = 1;i <= n - 2;i++){
				for(int j = i + 1;j <= n - 1 && (i+j)*3 < x*2 ;j++){
					int k = x - (i + j);
					if(k <= n && k > j){
//System.out.println("#"+i + ":" + j + ":" + k);
						cnt++;
					}
				}
			}
			System.out.println(cnt);
			n = s.nextInt();
			x = s.nextInt();
		}
	} hmw {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int x = s.nextInt();
		while(n != 0||x != 0){
			int cnt = 0;
			for(int i = 1;i <= n - 2;i++){
				for(int j = i + 1;j <= n - 1 && (i+j)*3 < x*2 ;j++){
					int k = x - (i + j);
					if(k <= n && k > j){
//System.out.println("#"+i + ":" + j + ":" + k);
						cnt++;
					}
				}
			}
			System.out.println(cnt);
			n = s.nextInt();
			x = s.nextInt();
		}
	} Scanner s = new Scanner(System.in); s new Scanner(System.in) int n = s.nextInt(); n s.nextInt() s.nextInt s int x = s.nextInt(); x s.nextInt() s.nextInt s while(n != 0||x != 0){
			int cnt = 0;
			for(int i = 1;i <= n - 2;i++){
				for(int j = i + 1;j <= n - 1 && (i+j)*3 < x*2 ;j++){
					int k = x - (i + j);
					if(k <= n && k > j){
//System.out.println("#"+i + ":" + j + ":" + k);
						cnt++;
					}
				}
			}
			System.out.println(cnt);
			n = s.nextInt();
			x = s.nextInt();
		} n != 0||x != 0 n != 0 n 0 x != 0 x 0 {
			int cnt = 0;
			for(int i = 1;i <= n - 2;i++){
				for(int j = i + 1;j <= n - 1 && (i+j)*3 < x*2 ;j++){
					int k = x - (i + j);
					if(k <= n && k > j){
//System.out.println("#"+i + ":" + j + ":" + k);
						cnt++;
					}
				}
			}
			System.out.println(cnt);
			n = s.nextInt();
			x = s.nextInt();
		} int cnt = 0; cnt 0 for(int i = 1;i <= n - 2;i++){
				for(int j = i + 1;j <= n - 1 && (i+j)*3 < x*2 ;j++){
					int k = x - (i + j);
					if(k <= n && k > j){
//System.out.println("#"+i + ":" + j + ":" + k);
						cnt++;
					}
				}
			} 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 && (i+j)*3 < x*2 ;j++){
					int k = x - (i + j);
					if(k <= n && k > j){
//System.out.println("#"+i + ":" + j + ":" + k);
						cnt++;
					}
				}
			} {
				for(int j = i + 1;j <= n - 1 && (i+j)*3 < x*2 ;j++){
					int k = x - (i + j);
					if(k <= n && k > j){
//System.out.println("#"+i + ":" + j + ":" + k);
						cnt++;
					}
				}
			} for(int j = i + 1;j <= n - 1 && (i+j)*3 < x*2 ;j++){
					int k = x - (i + j);
					if(k <= n && k > j){
//System.out.println("#"+i + ":" + j + ":" + k);
						cnt++;
					}
				} int j = i + 1; int j = i + 1; j i + 1 i 1 j <= n - 1 && (i+j)*3 < x*2 j <= n - 1 j n - 1 n 1 (i+j)*3 < x*2 (i+j)*3 (i+j) i j 3 x*2 x 2 j++ j++ j {
					int k = x - (i + j);
					if(k <= n && k > j){
//System.out.println("#"+i + ":" + j + ":" + k);
						cnt++;
					}
				} {
					int k = x - (i + j);
					if(k <= n && k > j){
//System.out.println("#"+i + ":" + j + ":" + k);
						cnt++;
					}
				} int k = x - (i + j); k x - (i + j) x (i + j) i j if(k <= n && k > j){
//System.out.println("#"+i + ":" + j + ":" + k);
						cnt++;
					} k <= n && k > j k <= n k n k > j k j {
//System.out.println("#"+i + ":" + j + ":" + k);
						cnt++;
					} cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt n = s.nextInt() n s.nextInt() s.nextInt s x = s.nextInt() x s.nextInt() s.nextInt s public static void main(String args[]){
		Main m = new Main();
		m.hmw();
	} main {
		Main m = new Main();
		m.hmw();
	} Main m = new Main(); m new Main() m.hmw() m.hmw m String args[] args public class Main {
	void hmw(){
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int x = s.nextInt();
		while(n != 0||x != 0){
			int cnt = 0;
			for(int i = 1;i <= n - 2;i++){
				for(int j = i + 1;j <= n - 1 && (i+j)*3 < x*2 ;j++){
					int k = x - (i + j);
					if(k <= n && k > j){
//System.out.println("#"+i + ":" + j + ":" + k);
						cnt++;
					}
				}
			}
			System.out.println(cnt);
			n = s.nextInt();
			x = s.nextInt();
		}
	}
	public static void main(String args[]){
		Main m = new Main();
		m.hmw();
	}
} public class Main {
	void hmw(){
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int x = s.nextInt();
		while(n != 0||x != 0){
			int cnt = 0;
			for(int i = 1;i <= n - 2;i++){
				for(int j = i + 1;j <= n - 1 && (i+j)*3 < x*2 ;j++){
					int k = x - (i + j);
					if(k <= n && k > j){
//System.out.println("#"+i + ":" + j + ":" + k);
						cnt++;
					}
				}
			}
			System.out.println(cnt);
			n = s.nextInt();
			x = s.nextInt();
		}
	}
	public static void main(String args[]){
		Main m = new Main();
		m.hmw();
	}
} Main
import java.util.Scanner;
public class Main {
	void hmw(){
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int x = s.nextInt();
		while(n != 0||x != 0){
			int cnt = 0;
			for(int i = 1;i <= n - 2;i++){
				for(int j = i + 1;j <= n - 1 && (i+j)*3 < x*2 ;j++){
					int k = x - (i + j);
					if(k <= n && k > j){
//System.out.println("#"+i + ":" + j + ":" + k);
						cnt++;
					}
				}
			}
			System.out.println(cnt);
			n = s.nextInt();
			x = s.nextInt();
		}
	}
	public static void main(String args[]){
		Main m = new Main();
		m.hmw();
	}
}