// ITP1_7_B How many ways?
import java.io.*;

public class Main {

   public static void main(String[] args) {
      try {
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
         while (true) {
            String strAry[] = br.readLine().split(" ");
            int n = Integer.parseInt(strAry[0]);
            int x = Integer.parseInt(strAry[1]);

            if ((n == 0 && x == 0) || (n < 3 || n > 100))
               break;

            System.out.println(combination(n, x));
         }
      }

      catch (Exception e) {
         System.err.println(e);
      }
   }

   private static int combination(int n, int x) {
      int count = 0;
      int a, b, c;
      for (int i = 1; i <= n; i++) {
         for (int j = 1; j <= n; j++) {
            if (i == j)
               break;
            for (int k = 1; k <= n; k++) {
               if (i == k || j == k)
                  break;
               if (i + j + k == x)
                  count++;
            }
         }
      }

      return count;
   }
} import java.io.*; io.* java public class Main {

   public static void main(String[] args) {
      try {
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
         while (true) {
            String strAry[] = br.readLine().split(" ");
            int n = Integer.parseInt(strAry[0]);
            int x = Integer.parseInt(strAry[1]);

            if ((n == 0 && x == 0) || (n < 3 || n > 100))
               break;

            System.out.println(combination(n, x));
         }
      }

      catch (Exception e) {
         System.err.println(e);
      }
   }

   private static int combination(int n, int x) {
      int count = 0;
      int a, b, c;
      for (int i = 1; i <= n; i++) {
         for (int j = 1; j <= n; j++) {
            if (i == j)
               break;
            for (int k = 1; k <= n; k++) {
               if (i == k || j == k)
                  break;
               if (i + j + k == x)
                  count++;
            }
         }
      }

      return count;
   }
} Main public static void main(String[] args) {
      try {
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
         while (true) {
            String strAry[] = br.readLine().split(" ");
            int n = Integer.parseInt(strAry[0]);
            int x = Integer.parseInt(strAry[1]);

            if ((n == 0 && x == 0) || (n < 3 || n > 100))
               break;

            System.out.println(combination(n, x));
         }
      }

      catch (Exception e) {
         System.err.println(e);
      }
   } main {
      try {
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
         while (true) {
            String strAry[] = br.readLine().split(" ");
            int n = Integer.parseInt(strAry[0]);
            int x = Integer.parseInt(strAry[1]);

            if ((n == 0 && x == 0) || (n < 3 || n > 100))
               break;

            System.out.println(combination(n, x));
         }
      }

      catch (Exception e) {
         System.err.println(e);
      }
   } try {
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
         while (true) {
            String strAry[] = br.readLine().split(" ");
            int n = Integer.parseInt(strAry[0]);
            int x = Integer.parseInt(strAry[1]);

            if ((n == 0 && x == 0) || (n < 3 || n > 100))
               break;

            System.out.println(combination(n, x));
         }
      }

      catch (Exception e) {
         System.err.println(e);
      } catch (Exception e) {
         System.err.println(e);
      } Exception e {
         System.err.println(e);
      } System.err.println(e) System.err.println System.err System System.err e {
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
         while (true) {
            String strAry[] = br.readLine().split(" ");
            int n = Integer.parseInt(strAry[0]);
            int x = Integer.parseInt(strAry[1]);

            if ((n == 0 && x == 0) || (n < 3 || n > 100))
               break;

            System.out.println(combination(n, x));
         }
      } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while (true) {
            String strAry[] = br.readLine().split(" ");
            int n = Integer.parseInt(strAry[0]);
            int x = Integer.parseInt(strAry[1]);

            if ((n == 0 && x == 0) || (n < 3 || n > 100))
               break;

            System.out.println(combination(n, x));
         } true {
            String strAry[] = br.readLine().split(" ");
            int n = Integer.parseInt(strAry[0]);
            int x = Integer.parseInt(strAry[1]);

            if ((n == 0 && x == 0) || (n < 3 || n > 100))
               break;

            System.out.println(combination(n, x));
         } String strAry[] = br.readLine().split(" "); strAry br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int n = Integer.parseInt(strAry[0]); n Integer.parseInt(strAry[0]) Integer.parseInt Integer strAry[0] strAry 0 int x = Integer.parseInt(strAry[1]); x Integer.parseInt(strAry[1]) Integer.parseInt Integer strAry[1] strAry 1 if ((n == 0 && x == 0) || (n < 3 || n > 100))
               break; (n == 0 && x == 0) || (n < 3 || n > 100) (n == 0 && x == 0) n == 0 n 0 x == 0 x 0 (n < 3 || n > 100) n < 3 n 3 n > 100 n 100 break; System.out.println(combination(n, x)) System.out.println System.out System System.out combination(n, x) combination n x String[] args args private static int combination(int n, int x) {
      int count = 0;
      int a, b, c;
      for (int i = 1; i <= n; i++) {
         for (int j = 1; j <= n; j++) {
            if (i == j)
               break;
            for (int k = 1; k <= n; k++) {
               if (i == k || j == k)
                  break;
               if (i + j + k == x)
                  count++;
            }
         }
      }

      return count;
   } combination {
      int count = 0;
      int a, b, c;
      for (int i = 1; i <= n; i++) {
         for (int j = 1; j <= n; j++) {
            if (i == j)
               break;
            for (int k = 1; k <= n; k++) {
               if (i == k || j == k)
                  break;
               if (i + j + k == x)
                  count++;
            }
         }
      }

      return count;
   } int count = 0; count 0 int a a b b c; c for (int i = 1; i <= n; i++) {
         for (int j = 1; j <= n; j++) {
            if (i == j)
               break;
            for (int k = 1; k <= n; k++) {
               if (i == k || j == k)
                  break;
               if (i + j + k == x)
                  count++;
            }
         }
      } int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
         for (int j = 1; j <= n; j++) {
            if (i == j)
               break;
            for (int k = 1; k <= n; k++) {
               if (i == k || j == k)
                  break;
               if (i + j + k == x)
                  count++;
            }
         }
      } {
         for (int j = 1; j <= n; j++) {
            if (i == j)
               break;
            for (int k = 1; k <= n; k++) {
               if (i == k || j == k)
                  break;
               if (i + j + k == x)
                  count++;
            }
         }
      } for (int j = 1; j <= n; j++) {
            if (i == j)
               break;
            for (int k = 1; k <= n; k++) {
               if (i == k || j == k)
                  break;
               if (i + j + k == x)
                  count++;
            }
         } int j = 1; int j = 1; j 1 j <= n j n j++ j++ j {
            if (i == j)
               break;
            for (int k = 1; k <= n; k++) {
               if (i == k || j == k)
                  break;
               if (i + j + k == x)
                  count++;
            }
         } {
            if (i == j)
               break;
            for (int k = 1; k <= n; k++) {
               if (i == k || j == k)
                  break;
               if (i + j + k == x)
                  count++;
            }
         } if (i == j)
               break; i == j i j break; for (int k = 1; k <= n; k++) {
               if (i == k || j == k)
                  break;
               if (i + j + k == x)
                  count++;
            } int k = 1; int k = 1; k 1 k <= n k n k++ k++ k {
               if (i == k || j == k)
                  break;
               if (i + j + k == x)
                  count++;
            } {
               if (i == k || j == k)
                  break;
               if (i + j + k == x)
                  count++;
            } if (i == k || j == k)
                  break; i == k || j == k i == k i k j == k j k break; if (i + j + k == x)
                  count++; i + j + k == x i + j + k i + j + k i j k x count++ count return count; count int n n int x x public class Main {

   public static void main(String[] args) {
      try {
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
         while (true) {
            String strAry[] = br.readLine().split(" ");
            int n = Integer.parseInt(strAry[0]);
            int x = Integer.parseInt(strAry[1]);

            if ((n == 0 && x == 0) || (n < 3 || n > 100))
               break;

            System.out.println(combination(n, x));
         }
      }

      catch (Exception e) {
         System.err.println(e);
      }
   }

   private static int combination(int n, int x) {
      int count = 0;
      int a, b, c;
      for (int i = 1; i <= n; i++) {
         for (int j = 1; j <= n; j++) {
            if (i == j)
               break;
            for (int k = 1; k <= n; k++) {
               if (i == k || j == k)
                  break;
               if (i + j + k == x)
                  count++;
            }
         }
      }

      return count;
   }
} public class Main {

   public static void main(String[] args) {
      try {
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
         while (true) {
            String strAry[] = br.readLine().split(" ");
            int n = Integer.parseInt(strAry[0]);
            int x = Integer.parseInt(strAry[1]);

            if ((n == 0 && x == 0) || (n < 3 || n > 100))
               break;

            System.out.println(combination(n, x));
         }
      }

      catch (Exception e) {
         System.err.println(e);
      }
   }

   private static int combination(int n, int x) {
      int count = 0;
      int a, b, c;
      for (int i = 1; i <= n; i++) {
         for (int j = 1; j <= n; j++) {
            if (i == j)
               break;
            for (int k = 1; k <= n; k++) {
               if (i == k || j == k)
                  break;
               if (i + j + k == x)
                  count++;
            }
         }
      }

      return count;
   }
} Main
// ITP1_7_B How many ways?
import java.io.*;

public class Main {

   public static void main(String[] args) {
      try {
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
         while (true) {
            String strAry[] = br.readLine().split(" ");
            int n = Integer.parseInt(strAry[0]);
            int x = Integer.parseInt(strAry[1]);

            if ((n == 0 && x == 0) || (n < 3 || n > 100))
               break;

            System.out.println(combination(n, x));
         }
      }

      catch (Exception e) {
         System.err.println(e);
      }
   }

   private static int combination(int n, int x) {
      int count = 0;
      int a, b, c;
      for (int i = 1; i <= n; i++) {
         for (int j = 1; j <= n; j++) {
            if (i == j)
               break;
            for (int k = 1; k <= n; k++) {
               if (i == k || j == k)
                  break;
               if (i + j + k == x)
                  count++;
            }
         }
      }

      return count;
   }
}