import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
	Scanner scan = new Scanner(System.in);
	while (scan.hasNext()) {
	    int count = 0;
	    int n = scan.nextInt();
	    int x = scan.nextInt();
	    if (n == 0 && x == 0) {
		break;
	    }
	    for (int i = 1; i < n - 1; i++) {
		if (i > x) {
		    break;
		}
		for (int j = i + 1; j < n; j++) {
		    if (j + i > x) {
			break;
		    }
		    for (int k = j + 1; k < n + 1; k++) {
			if (j + i + k > x) {
			    break;
			}
			if (j + i + k == x) {
			    count++;
			    break;
			}
		    }
		}
	    }
	    System.out.println(count);
	}
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args) {
	Scanner scan = new Scanner(System.in);
	while (scan.hasNext()) {
	    int count = 0;
	    int n = scan.nextInt();
	    int x = scan.nextInt();
	    if (n == 0 && x == 0) {
		break;
	    }
	    for (int i = 1; i < n - 1; i++) {
		if (i > x) {
		    break;
		}
		for (int j = i + 1; j < n; j++) {
		    if (j + i > x) {
			break;
		    }
		    for (int k = j + 1; k < n + 1; k++) {
			if (j + i + k > x) {
			    break;
			}
			if (j + i + k == x) {
			    count++;
			    break;
			}
		    }
		}
	    }
	    System.out.println(count);
	}
    }
} Main public static void main(String[] args) {
	Scanner scan = new Scanner(System.in);
	while (scan.hasNext()) {
	    int count = 0;
	    int n = scan.nextInt();
	    int x = scan.nextInt();
	    if (n == 0 && x == 0) {
		break;
	    }
	    for (int i = 1; i < n - 1; i++) {
		if (i > x) {
		    break;
		}
		for (int j = i + 1; j < n; j++) {
		    if (j + i > x) {
			break;
		    }
		    for (int k = j + 1; k < n + 1; k++) {
			if (j + i + k > x) {
			    break;
			}
			if (j + i + k == x) {
			    count++;
			    break;
			}
		    }
		}
	    }
	    System.out.println(count);
	}
    } main {
	Scanner scan = new Scanner(System.in);
	while (scan.hasNext()) {
	    int count = 0;
	    int n = scan.nextInt();
	    int x = scan.nextInt();
	    if (n == 0 && x == 0) {
		break;
	    }
	    for (int i = 1; i < n - 1; i++) {
		if (i > x) {
		    break;
		}
		for (int j = i + 1; j < n; j++) {
		    if (j + i > x) {
			break;
		    }
		    for (int k = j + 1; k < n + 1; k++) {
			if (j + i + k > x) {
			    break;
			}
			if (j + i + k == x) {
			    count++;
			    break;
			}
		    }
		}
	    }
	    System.out.println(count);
	}
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) while (scan.hasNext()) {
	    int count = 0;
	    int n = scan.nextInt();
	    int x = scan.nextInt();
	    if (n == 0 && x == 0) {
		break;
	    }
	    for (int i = 1; i < n - 1; i++) {
		if (i > x) {
		    break;
		}
		for (int j = i + 1; j < n; j++) {
		    if (j + i > x) {
			break;
		    }
		    for (int k = j + 1; k < n + 1; k++) {
			if (j + i + k > x) {
			    break;
			}
			if (j + i + k == x) {
			    count++;
			    break;
			}
		    }
		}
	    }
	    System.out.println(count);
	} scan.hasNext() scan.hasNext scan {
	    int count = 0;
	    int n = scan.nextInt();
	    int x = scan.nextInt();
	    if (n == 0 && x == 0) {
		break;
	    }
	    for (int i = 1; i < n - 1; i++) {
		if (i > x) {
		    break;
		}
		for (int j = i + 1; j < n; j++) {
		    if (j + i > x) {
			break;
		    }
		    for (int k = j + 1; k < n + 1; k++) {
			if (j + i + k > x) {
			    break;
			}
			if (j + i + k == x) {
			    count++;
			    break;
			}
		    }
		}
	    }
	    System.out.println(count);
	} int count = 0; count 0 int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int x = scan.nextInt(); x scan.nextInt() scan.nextInt scan 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 - 1; i++) {
		if (i > x) {
		    break;
		}
		for (int j = i + 1; j < n; j++) {
		    if (j + i > x) {
			break;
		    }
		    for (int k = j + 1; k < n + 1; k++) {
			if (j + i + k > x) {
			    break;
			}
			if (j + i + k == x) {
			    count++;
			    break;
			}
		    }
		}
	    } int i = 1; int i = 1; i 1 i < n - 1 i n - 1 n 1 i++ i++ i {
		if (i > x) {
		    break;
		}
		for (int j = i + 1; j < n; j++) {
		    if (j + i > x) {
			break;
		    }
		    for (int k = j + 1; k < n + 1; k++) {
			if (j + i + k > x) {
			    break;
			}
			if (j + i + k == x) {
			    count++;
			    break;
			}
		    }
		}
	    } {
		if (i > x) {
		    break;
		}
		for (int j = i + 1; j < n; j++) {
		    if (j + i > x) {
			break;
		    }
		    for (int k = j + 1; k < n + 1; k++) {
			if (j + i + k > x) {
			    break;
			}
			if (j + i + k == x) {
			    count++;
			    break;
			}
		    }
		}
	    } if (i > x) {
		    break;
		} i > x i x {
		    break;
		} break; for (int j = i + 1; j < n; j++) {
		    if (j + i > x) {
			break;
		    }
		    for (int k = j + 1; k < n + 1; k++) {
			if (j + i + k > x) {
			    break;
			}
			if (j + i + k == x) {
			    count++;
			    break;
			}
		    }
		} int j = i + 1; int j = i + 1; j i + 1 i 1 j < n j n j++ j++ j {
		    if (j + i > x) {
			break;
		    }
		    for (int k = j + 1; k < n + 1; k++) {
			if (j + i + k > x) {
			    break;
			}
			if (j + i + k == x) {
			    count++;
			    break;
			}
		    }
		} {
		    if (j + i > x) {
			break;
		    }
		    for (int k = j + 1; k < n + 1; k++) {
			if (j + i + k > x) {
			    break;
			}
			if (j + i + k == x) {
			    count++;
			    break;
			}
		    }
		} if (j + i > x) {
			break;
		    } j + i > x j + i j i x {
			break;
		    } break; for (int k = j + 1; k < n + 1; k++) {
			if (j + i + k > x) {
			    break;
			}
			if (j + i + k == x) {
			    count++;
			    break;
			}
		    } int k = j + 1; int k = j + 1; k j + 1 j 1 k < n + 1 k n + 1 n 1 k++ k++ k {
			if (j + i + k > x) {
			    break;
			}
			if (j + i + k == x) {
			    count++;
			    break;
			}
		    } {
			if (j + i + k > x) {
			    break;
			}
			if (j + i + k == x) {
			    count++;
			    break;
			}
		    } if (j + i + k > x) {
			    break;
			} j + i + k > x j + i + k j + i + k j i k x {
			    break;
			} break; if (j + i + k == x) {
			    count++;
			    break;
			} j + i + k == x j + i + k j + i + k j i k x {
			    count++;
			    break;
			} count++ count break; 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) {
	Scanner scan = new Scanner(System.in);
	while (scan.hasNext()) {
	    int count = 0;
	    int n = scan.nextInt();
	    int x = scan.nextInt();
	    if (n == 0 && x == 0) {
		break;
	    }
	    for (int i = 1; i < n - 1; i++) {
		if (i > x) {
		    break;
		}
		for (int j = i + 1; j < n; j++) {
		    if (j + i > x) {
			break;
		    }
		    for (int k = j + 1; k < n + 1; k++) {
			if (j + i + k > x) {
			    break;
			}
			if (j + i + k == x) {
			    count++;
			    break;
			}
		    }
		}
	    }
	    System.out.println(count);
	}
    }
} public class Main{
    public static void main(String[] args) {
	Scanner scan = new Scanner(System.in);
	while (scan.hasNext()) {
	    int count = 0;
	    int n = scan.nextInt();
	    int x = scan.nextInt();
	    if (n == 0 && x == 0) {
		break;
	    }
	    for (int i = 1; i < n - 1; i++) {
		if (i > x) {
		    break;
		}
		for (int j = i + 1; j < n; j++) {
		    if (j + i > x) {
			break;
		    }
		    for (int k = j + 1; k < n + 1; k++) {
			if (j + i + k > x) {
			    break;
			}
			if (j + i + k == x) {
			    count++;
			    break;
			}
		    }
		}
	    }
	    System.out.println(count);
	}
    }
} Main
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
	Scanner scan = new Scanner(System.in);
	while (scan.hasNext()) {
	    int count = 0;
	    int n = scan.nextInt();
	    int x = scan.nextInt();
	    if (n == 0 && x == 0) {
		break;
	    }
	    for (int i = 1; i < n - 1; i++) {
		if (i > x) {
		    break;
		}
		for (int j = i + 1; j < n; j++) {
		    if (j + i > x) {
			break;
		    }
		    for (int k = j + 1; k < n + 1; k++) {
			if (j + i + k > x) {
			    break;
			}
			if (j + i + k == x) {
			    count++;
			    break;
			}
		    }
		}
	    }
	    System.out.println(count);
	}
    }
}