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

