import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(true) {
      int count = 0;
      int n = sc.nextInt();
      int x = sc.nextInt();
      if(n == 0 && x == 0) {
        break;
      } else {
        for(int i = 1; i < n + 1; i++) {
          for(int j = 1; j < n + 1; j++) {
            int k = x - i - j;
            if(i != j && i != k && j != k && k < n + 1 && k > 0) {
              count++;
            }
          }
        }
        System.out.println(count / 6);
      }
    }
  }
}
 import java.util.*; util.* java public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(true) {
      int count = 0;
      int n = sc.nextInt();
      int x = sc.nextInt();
      if(n == 0 && x == 0) {
        break;
      } else {
        for(int i = 1; i < n + 1; i++) {
          for(int j = 1; j < n + 1; j++) {
            int k = x - i - j;
            if(i != j && i != k && j != k && k < n + 1 && k > 0) {
              count++;
            }
          }
        }
        System.out.println(count / 6);
      }
    }
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(true) {
      int count = 0;
      int n = sc.nextInt();
      int x = sc.nextInt();
      if(n == 0 && x == 0) {
        break;
      } else {
        for(int i = 1; i < n + 1; i++) {
          for(int j = 1; j < n + 1; j++) {
            int k = x - i - j;
            if(i != j && i != k && j != k && k < n + 1 && k > 0) {
              count++;
            }
          }
        }
        System.out.println(count / 6);
      }
    }
  } main {
    Scanner sc = new Scanner(System.in);
    while(true) {
      int count = 0;
      int n = sc.nextInt();
      int x = sc.nextInt();
      if(n == 0 && x == 0) {
        break;
      } else {
        for(int i = 1; i < n + 1; i++) {
          for(int j = 1; j < n + 1; j++) {
            int k = x - i - j;
            if(i != j && i != k && j != k && k < n + 1 && k > 0) {
              count++;
            }
          }
        }
        System.out.println(count / 6);
      }
    }
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true) {
      int count = 0;
      int n = sc.nextInt();
      int x = sc.nextInt();
      if(n == 0 && x == 0) {
        break;
      } else {
        for(int i = 1; i < n + 1; i++) {
          for(int j = 1; j < n + 1; j++) {
            int k = x - i - j;
            if(i != j && i != k && j != k && k < n + 1 && k > 0) {
              count++;
            }
          }
        }
        System.out.println(count / 6);
      }
    } true {
      int count = 0;
      int n = sc.nextInt();
      int x = sc.nextInt();
      if(n == 0 && x == 0) {
        break;
      } else {
        for(int i = 1; i < n + 1; i++) {
          for(int j = 1; j < n + 1; j++) {
            int k = x - i - j;
            if(i != j && i != k && j != k && k < n + 1 && k > 0) {
              count++;
            }
          }
        }
        System.out.println(count / 6);
      }
    } int count = 0; count 0 int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc if(n == 0 && x == 0) {
        break;
      } else {
        for(int i = 1; i < n + 1; i++) {
          for(int j = 1; j < n + 1; j++) {
            int k = x - i - j;
            if(i != j && i != k && j != k && k < n + 1 && k > 0) {
              count++;
            }
          }
        }
        System.out.println(count / 6);
      } n == 0 && x == 0 n == 0 n 0 x == 0 x 0 {
        break;
      } break; {
        for(int i = 1; i < n + 1; i++) {
          for(int j = 1; j < n + 1; j++) {
            int k = x - i - j;
            if(i != j && i != k && j != k && k < n + 1 && k > 0) {
              count++;
            }
          }
        }
        System.out.println(count / 6);
      } for(int i = 1; i < n + 1; i++) {
          for(int j = 1; j < n + 1; j++) {
            int k = x - i - j;
            if(i != j && i != k && j != k && k < n + 1 && k > 0) {
              count++;
            }
          }
        } int i = 1; int i = 1; i 1 i < n + 1 i n + 1 n 1 i++ i++ i {
          for(int j = 1; j < n + 1; j++) {
            int k = x - i - j;
            if(i != j && i != k && j != k && k < n + 1 && k > 0) {
              count++;
            }
          }
        } {
          for(int j = 1; j < n + 1; j++) {
            int k = x - i - j;
            if(i != j && i != k && j != k && k < n + 1 && k > 0) {
              count++;
            }
          }
        } for(int j = 1; j < n + 1; j++) {
            int k = x - i - j;
            if(i != j && i != k && j != k && k < n + 1 && k > 0) {
              count++;
            }
          } int j = 1; int j = 1; j 1 j < n + 1 j n + 1 n 1 j++ j++ j {
            int k = x - i - j;
            if(i != j && i != k && j != k && k < n + 1 && k > 0) {
              count++;
            }
          } {
            int k = x - i - j;
            if(i != j && i != k && j != k && k < n + 1 && k > 0) {
              count++;
            }
          } int k = x - i - j; k x - i - j x - i - j x i j if(i != j && i != k && j != k && k < n + 1 && k > 0) {
              count++;
            } i != j && i != k && j != k && k < n + 1 && k > 0 k < n + 1 j != k i != j && i != k && j != k && k < n + 1 && k > 0 i != j i j i != k i k j != k j k k < n + 1 k n + 1 n 1 k > 0 k 0 {
              count++;
            } count++ count System.out.println(count / 6) System.out.println System.out System System.out count / 6 count 6 String[] args args public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(true) {
      int count = 0;
      int n = sc.nextInt();
      int x = sc.nextInt();
      if(n == 0 && x == 0) {
        break;
      } else {
        for(int i = 1; i < n + 1; i++) {
          for(int j = 1; j < n + 1; j++) {
            int k = x - i - j;
            if(i != j && i != k && j != k && k < n + 1 && k > 0) {
              count++;
            }
          }
        }
        System.out.println(count / 6);
      }
    }
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(true) {
      int count = 0;
      int n = sc.nextInt();
      int x = sc.nextInt();
      if(n == 0 && x == 0) {
        break;
      } else {
        for(int i = 1; i < n + 1; i++) {
          for(int j = 1; j < n + 1; j++) {
            int k = x - i - j;
            if(i != j && i != k && j != k && k < n + 1 && k > 0) {
              count++;
            }
          }
        }
        System.out.println(count / 6);
      }
    }
  }
} Main
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(true) {
      int count = 0;
      int n = sc.nextInt();
      int x = sc.nextInt();
      if(n == 0 && x == 0) {
        break;
      } else {
        for(int i = 1; i < n + 1; i++) {
          for(int j = 1; j < n + 1; j++) {
            int k = x - i - j;
            if(i != j && i != k && j != k && k < n + 1 && k > 0) {
              count++;
            }
          }
        }
        System.out.println(count / 6);
      }
    }
  }
}

