// 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;
   }
}
/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz