import java.util.*;

public class Main {
	public static void main(String[] args) {
				
		Scanner sc = new Scanner(System.in);
		LinkedList<Integer> ll = new LinkedList<>();
		
		int n = 999;
		int x = 999;
		int cnt = 0;
		while(n != 0 || x != 0) {
			n = sc.nextInt();
			x = sc.nextInt();
			int ans = 0;
			if(n == 0 && x == 0) {
				break;
			} else {
				cnt++;
				for(int i = 1; i <= n; i++) {
					for(int j = 1; j < i; j++) {
						for(int k = 1; k < j; k++) {
							if(i + k + j == x) {
								ans++;
							}
						}
					}
				}
				ll.add(ans);
			}
		}
		
		for(int i = 0; i < cnt; i++) {
			System.out.println(ll.get(i));
		}
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
				
		Scanner sc = new Scanner(System.in);
		LinkedList<Integer> ll = new LinkedList<>();
		
		int n = 999;
		int x = 999;
		int cnt = 0;
		while(n != 0 || x != 0) {
			n = sc.nextInt();
			x = sc.nextInt();
			int ans = 0;
			if(n == 0 && x == 0) {
				break;
			} else {
				cnt++;
				for(int i = 1; i <= n; i++) {
					for(int j = 1; j < i; j++) {
						for(int k = 1; k < j; k++) {
							if(i + k + j == x) {
								ans++;
							}
						}
					}
				}
				ll.add(ans);
			}
		}
		
		for(int i = 0; i < cnt; i++) {
			System.out.println(ll.get(i));
		}
	}
} Main public static void main(String[] args) {
				
		Scanner sc = new Scanner(System.in);
		LinkedList<Integer> ll = new LinkedList<>();
		
		int n = 999;
		int x = 999;
		int cnt = 0;
		while(n != 0 || x != 0) {
			n = sc.nextInt();
			x = sc.nextInt();
			int ans = 0;
			if(n == 0 && x == 0) {
				break;
			} else {
				cnt++;
				for(int i = 1; i <= n; i++) {
					for(int j = 1; j < i; j++) {
						for(int k = 1; k < j; k++) {
							if(i + k + j == x) {
								ans++;
							}
						}
					}
				}
				ll.add(ans);
			}
		}
		
		for(int i = 0; i < cnt; i++) {
			System.out.println(ll.get(i));
		}
	} main {
				
		Scanner sc = new Scanner(System.in);
		LinkedList<Integer> ll = new LinkedList<>();
		
		int n = 999;
		int x = 999;
		int cnt = 0;
		while(n != 0 || x != 0) {
			n = sc.nextInt();
			x = sc.nextInt();
			int ans = 0;
			if(n == 0 && x == 0) {
				break;
			} else {
				cnt++;
				for(int i = 1; i <= n; i++) {
					for(int j = 1; j < i; j++) {
						for(int k = 1; k < j; k++) {
							if(i + k + j == x) {
								ans++;
							}
						}
					}
				}
				ll.add(ans);
			}
		}
		
		for(int i = 0; i < cnt; i++) {
			System.out.println(ll.get(i));
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) LinkedList<Integer> ll = new LinkedList<>(); ll new LinkedList<>() int n = 999; n 999 int x = 999; x 999 int cnt = 0; cnt 0 while(n != 0 || x != 0) {
			n = sc.nextInt();
			x = sc.nextInt();
			int ans = 0;
			if(n == 0 && x == 0) {
				break;
			} else {
				cnt++;
				for(int i = 1; i <= n; i++) {
					for(int j = 1; j < i; j++) {
						for(int k = 1; k < j; k++) {
							if(i + k + j == x) {
								ans++;
							}
						}
					}
				}
				ll.add(ans);
			}
		} n != 0 || x != 0 n != 0 n 0 x != 0 x 0 {
			n = sc.nextInt();
			x = sc.nextInt();
			int ans = 0;
			if(n == 0 && x == 0) {
				break;
			} else {
				cnt++;
				for(int i = 1; i <= n; i++) {
					for(int j = 1; j < i; j++) {
						for(int k = 1; k < j; k++) {
							if(i + k + j == x) {
								ans++;
							}
						}
					}
				}
				ll.add(ans);
			}
		} n = sc.nextInt() n sc.nextInt() sc.nextInt sc x = sc.nextInt() x sc.nextInt() sc.nextInt sc int ans = 0; ans 0 if(n == 0 && x == 0) {
				break;
			} else {
				cnt++;
				for(int i = 1; i <= n; i++) {
					for(int j = 1; j < i; j++) {
						for(int k = 1; k < j; k++) {
							if(i + k + j == x) {
								ans++;
							}
						}
					}
				}
				ll.add(ans);
			} n == 0 && x == 0 n == 0 n 0 x == 0 x 0 {
				break;
			} break; {
				cnt++;
				for(int i = 1; i <= n; i++) {
					for(int j = 1; j < i; j++) {
						for(int k = 1; k < j; k++) {
							if(i + k + j == x) {
								ans++;
							}
						}
					}
				}
				ll.add(ans);
			} cnt++ cnt for(int i = 1; i <= n; i++) {
					for(int j = 1; j < i; j++) {
						for(int k = 1; k < j; k++) {
							if(i + k + j == x) {
								ans++;
							}
						}
					}
				} int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
					for(int j = 1; j < i; j++) {
						for(int k = 1; k < j; k++) {
							if(i + k + j == x) {
								ans++;
							}
						}
					}
				} {
					for(int j = 1; j < i; j++) {
						for(int k = 1; k < j; k++) {
							if(i + k + j == x) {
								ans++;
							}
						}
					}
				} for(int j = 1; j < i; j++) {
						for(int k = 1; k < j; k++) {
							if(i + k + j == x) {
								ans++;
							}
						}
					} int j = 1; int j = 1; j 1 j < i j i j++ j++ j {
						for(int k = 1; k < j; k++) {
							if(i + k + j == x) {
								ans++;
							}
						}
					} {
						for(int k = 1; k < j; k++) {
							if(i + k + j == x) {
								ans++;
							}
						}
					} for(int k = 1; k < j; k++) {
							if(i + k + j == x) {
								ans++;
							}
						} int k = 1; int k = 1; k 1 k < j k j k++ k++ k {
							if(i + k + j == x) {
								ans++;
							}
						} {
							if(i + k + j == x) {
								ans++;
							}
						} if(i + k + j == x) {
								ans++;
							} i + k + j == x i + k + j i + k + j i k j x {
								ans++;
							} ans++ ans ll.add(ans) ll.add ll ans for(int i = 0; i < cnt; i++) {
			System.out.println(ll.get(i));
		} int i = 0; int i = 0; i 0 i < cnt i cnt i++ i++ i {
			System.out.println(ll.get(i));
		} {
			System.out.println(ll.get(i));
		} System.out.println(ll.get(i)) System.out.println System.out System System.out ll.get(i) ll.get ll i String[] args args public class Main {
	public static void main(String[] args) {
				
		Scanner sc = new Scanner(System.in);
		LinkedList<Integer> ll = new LinkedList<>();
		
		int n = 999;
		int x = 999;
		int cnt = 0;
		while(n != 0 || x != 0) {
			n = sc.nextInt();
			x = sc.nextInt();
			int ans = 0;
			if(n == 0 && x == 0) {
				break;
			} else {
				cnt++;
				for(int i = 1; i <= n; i++) {
					for(int j = 1; j < i; j++) {
						for(int k = 1; k < j; k++) {
							if(i + k + j == x) {
								ans++;
							}
						}
					}
				}
				ll.add(ans);
			}
		}
		
		for(int i = 0; i < cnt; i++) {
			System.out.println(ll.get(i));
		}
	}
} public class Main {
	public static void main(String[] args) {
				
		Scanner sc = new Scanner(System.in);
		LinkedList<Integer> ll = new LinkedList<>();
		
		int n = 999;
		int x = 999;
		int cnt = 0;
		while(n != 0 || x != 0) {
			n = sc.nextInt();
			x = sc.nextInt();
			int ans = 0;
			if(n == 0 && x == 0) {
				break;
			} else {
				cnt++;
				for(int i = 1; i <= n; i++) {
					for(int j = 1; j < i; j++) {
						for(int k = 1; k < j; k++) {
							if(i + k + j == x) {
								ans++;
							}
						}
					}
				}
				ll.add(ans);
			}
		}
		
		for(int i = 0; i < cnt; i++) {
			System.out.println(ll.get(i));
		}
	}
} Main
import java.util.*;

public class Main {
	public static void main(String[] args) {
				
		Scanner sc = new Scanner(System.in);
		LinkedList<Integer> ll = new LinkedList<>();
		
		int n = 999;
		int x = 999;
		int cnt = 0;
		while(n != 0 || x != 0) {
			n = sc.nextInt();
			x = sc.nextInt();
			int ans = 0;
			if(n == 0 && x == 0) {
				break;
			} else {
				cnt++;
				for(int i = 1; i <= n; i++) {
					for(int j = 1; j < i; j++) {
						for(int k = 1; k < j; k++) {
							if(i + k + j == x) {
								ans++;
							}
						}
					}
				}
				ll.add(ans);
			}
		}
		
		for(int i = 0; i < cnt; i++) {
			System.out.println(ll.get(i));
		}
	}
}