import java.util.*;
import java.lang.StringBuilder;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int c = 0;
		int n,x;
		do{
			n = sc.nextInt();
			x = sc.nextInt();
			c = 0;
			if(n==0&&x==0){
				break;
			}
			for(int i = 1;i <= n;i++){
				for(int o = 1;o <= n;o++){
					if(o==i){
						break;
					}
					for(int k = 1;k <= n;k++){
						if(i==k){
							break;
						}else if(o==k){
							break;
						}else if(i+o+k==x){
							++c;
						}
					}
				}
			}
			sb.append(c).append("\n");
		}while(true);
		System.out.print(sb);
	}
} import java.util.*; util.* java import java.lang.StringBuilder; StringBuilder java.lang public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int c = 0;
		int n,x;
		do{
			n = sc.nextInt();
			x = sc.nextInt();
			c = 0;
			if(n==0&&x==0){
				break;
			}
			for(int i = 1;i <= n;i++){
				for(int o = 1;o <= n;o++){
					if(o==i){
						break;
					}
					for(int k = 1;k <= n;k++){
						if(i==k){
							break;
						}else if(o==k){
							break;
						}else if(i+o+k==x){
							++c;
						}
					}
				}
			}
			sb.append(c).append("\n");
		}while(true);
		System.out.print(sb);
	}
} Main public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int c = 0;
		int n,x;
		do{
			n = sc.nextInt();
			x = sc.nextInt();
			c = 0;
			if(n==0&&x==0){
				break;
			}
			for(int i = 1;i <= n;i++){
				for(int o = 1;o <= n;o++){
					if(o==i){
						break;
					}
					for(int k = 1;k <= n;k++){
						if(i==k){
							break;
						}else if(o==k){
							break;
						}else if(i+o+k==x){
							++c;
						}
					}
				}
			}
			sb.append(c).append("\n");
		}while(true);
		System.out.print(sb);
	} main {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int c = 0;
		int n,x;
		do{
			n = sc.nextInt();
			x = sc.nextInt();
			c = 0;
			if(n==0&&x==0){
				break;
			}
			for(int i = 1;i <= n;i++){
				for(int o = 1;o <= n;o++){
					if(o==i){
						break;
					}
					for(int k = 1;k <= n;k++){
						if(i==k){
							break;
						}else if(o==k){
							break;
						}else if(i+o+k==x){
							++c;
						}
					}
				}
			}
			sb.append(c).append("\n");
		}while(true);
		System.out.print(sb);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) StringBuilder sb = new StringBuilder(); sb new StringBuilder() int c = 0; c 0 int n n x; x do{
			n = sc.nextInt();
			x = sc.nextInt();
			c = 0;
			if(n==0&&x==0){
				break;
			}
			for(int i = 1;i <= n;i++){
				for(int o = 1;o <= n;o++){
					if(o==i){
						break;
					}
					for(int k = 1;k <= n;k++){
						if(i==k){
							break;
						}else if(o==k){
							break;
						}else if(i+o+k==x){
							++c;
						}
					}
				}
			}
			sb.append(c).append("\n");
		}while(true); true {
			n = sc.nextInt();
			x = sc.nextInt();
			c = 0;
			if(n==0&&x==0){
				break;
			}
			for(int i = 1;i <= n;i++){
				for(int o = 1;o <= n;o++){
					if(o==i){
						break;
					}
					for(int k = 1;k <= n;k++){
						if(i==k){
							break;
						}else if(o==k){
							break;
						}else if(i+o+k==x){
							++c;
						}
					}
				}
			}
			sb.append(c).append("\n");
		} n = sc.nextInt() n sc.nextInt() sc.nextInt sc x = sc.nextInt() x sc.nextInt() sc.nextInt sc c = 0 c 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 <= n;i++){
				for(int o = 1;o <= n;o++){
					if(o==i){
						break;
					}
					for(int k = 1;k <= n;k++){
						if(i==k){
							break;
						}else if(o==k){
							break;
						}else if(i+o+k==x){
							++c;
						}
					}
				}
			} int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
				for(int o = 1;o <= n;o++){
					if(o==i){
						break;
					}
					for(int k = 1;k <= n;k++){
						if(i==k){
							break;
						}else if(o==k){
							break;
						}else if(i+o+k==x){
							++c;
						}
					}
				}
			} {
				for(int o = 1;o <= n;o++){
					if(o==i){
						break;
					}
					for(int k = 1;k <= n;k++){
						if(i==k){
							break;
						}else if(o==k){
							break;
						}else if(i+o+k==x){
							++c;
						}
					}
				}
			} for(int o = 1;o <= n;o++){
					if(o==i){
						break;
					}
					for(int k = 1;k <= n;k++){
						if(i==k){
							break;
						}else if(o==k){
							break;
						}else if(i+o+k==x){
							++c;
						}
					}
				} int o = 1; int o = 1; o 1 o <= n o n o++ o++ o {
					if(o==i){
						break;
					}
					for(int k = 1;k <= n;k++){
						if(i==k){
							break;
						}else if(o==k){
							break;
						}else if(i+o+k==x){
							++c;
						}
					}
				} {
					if(o==i){
						break;
					}
					for(int k = 1;k <= n;k++){
						if(i==k){
							break;
						}else if(o==k){
							break;
						}else if(i+o+k==x){
							++c;
						}
					}
				} if(o==i){
						break;
					} o==i o i {
						break;
					} break; for(int k = 1;k <= n;k++){
						if(i==k){
							break;
						}else if(o==k){
							break;
						}else if(i+o+k==x){
							++c;
						}
					} int k = 1; int k = 1; k 1 k <= n k n k++ k++ k {
						if(i==k){
							break;
						}else if(o==k){
							break;
						}else if(i+o+k==x){
							++c;
						}
					} {
						if(i==k){
							break;
						}else if(o==k){
							break;
						}else if(i+o+k==x){
							++c;
						}
					} if(i==k){
							break;
						}else if(o==k){
							break;
						}else if(i+o+k==x){
							++c;
						} i==k i k {
							break;
						} break; if(o==k){
							break;
						}else if(i+o+k==x){
							++c;
						} o==k o k {
							break;
						} break; if(i+o+k==x){
							++c;
						} i+o+k==x i+o+k i+o+k i o k x {
							++c;
						} ++c c sb.append(c).append("\n") sb.append(c).append sb.append(c) sb.append sb c "\n" System.out.print(sb) System.out.print System.out System System.out sb String[] args args public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int c = 0;
		int n,x;
		do{
			n = sc.nextInt();
			x = sc.nextInt();
			c = 0;
			if(n==0&&x==0){
				break;
			}
			for(int i = 1;i <= n;i++){
				for(int o = 1;o <= n;o++){
					if(o==i){
						break;
					}
					for(int k = 1;k <= n;k++){
						if(i==k){
							break;
						}else if(o==k){
							break;
						}else if(i+o+k==x){
							++c;
						}
					}
				}
			}
			sb.append(c).append("\n");
		}while(true);
		System.out.print(sb);
	}
} public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int c = 0;
		int n,x;
		do{
			n = sc.nextInt();
			x = sc.nextInt();
			c = 0;
			if(n==0&&x==0){
				break;
			}
			for(int i = 1;i <= n;i++){
				for(int o = 1;o <= n;o++){
					if(o==i){
						break;
					}
					for(int k = 1;k <= n;k++){
						if(i==k){
							break;
						}else if(o==k){
							break;
						}else if(i+o+k==x){
							++c;
						}
					}
				}
			}
			sb.append(c).append("\n");
		}while(true);
		System.out.print(sb);
	}
} Main
import java.util.*;
import java.lang.StringBuilder;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int c = 0;
		int n,x;
		do{
			n = sc.nextInt();
			x = sc.nextInt();
			c = 0;
			if(n==0&&x==0){
				break;
			}
			for(int i = 1;i <= n;i++){
				for(int o = 1;o <= n;o++){
					if(o==i){
						break;
					}
					for(int k = 1;k <= n;k++){
						if(i==k){
							break;
						}else if(o==k){
							break;
						}else if(i+o+k==x){
							++c;
						}
					}
				}
			}
			sb.append(c).append("\n");
		}while(true);
		System.out.print(sb);
	}
}