/* ITP1_7_B */
import java.io.*;

class Main
{
  public static void main(String[] args)
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringBuilder sb = new StringBuilder();
      String str = "";

      while((str = br.readLine()).equals("0 0") == false){
        // input
        String[] input = str.split(" ");
        int n = Integer.parseInt(input[0]);
        int x = Integer.parseInt(input[1]);
        if(n < 3 || n > 100) return;

        int count = 0;
        // finish
        if(n == 0 && x == 0) break;
        // check
        for(int i = 1; i <= n; i++){
          for(int j = (i + 1); (i + j) < x; j++){
            int k = x - i - j;
            if(k > j && k <= n) count++;
          }
        }
        sb.append(count + "\n");
      }
      // output
      System.out.print(sb);
    }catch(Exception e){
      System.out.println(e);
    }
  }
} import java.io.*; io.* java class Main
{
  public static void main(String[] args)
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringBuilder sb = new StringBuilder();
      String str = "";

      while((str = br.readLine()).equals("0 0") == false){
        // input
        String[] input = str.split(" ");
        int n = Integer.parseInt(input[0]);
        int x = Integer.parseInt(input[1]);
        if(n < 3 || n > 100) return;

        int count = 0;
        // finish
        if(n == 0 && x == 0) break;
        // check
        for(int i = 1; i <= n; i++){
          for(int j = (i + 1); (i + j) < x; j++){
            int k = x - i - j;
            if(k > j && k <= n) count++;
          }
        }
        sb.append(count + "\n");
      }
      // output
      System.out.print(sb);
    }catch(Exception e){
      System.out.println(e);
    }
  }
} Main public static void main(String[] args)
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringBuilder sb = new StringBuilder();
      String str = "";

      while((str = br.readLine()).equals("0 0") == false){
        // input
        String[] input = str.split(" ");
        int n = Integer.parseInt(input[0]);
        int x = Integer.parseInt(input[1]);
        if(n < 3 || n > 100) return;

        int count = 0;
        // finish
        if(n == 0 && x == 0) break;
        // check
        for(int i = 1; i <= n; i++){
          for(int j = (i + 1); (i + j) < x; j++){
            int k = x - i - j;
            if(k > j && k <= n) count++;
          }
        }
        sb.append(count + "\n");
      }
      // output
      System.out.print(sb);
    }catch(Exception e){
      System.out.println(e);
    }
  } main {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringBuilder sb = new StringBuilder();
      String str = "";

      while((str = br.readLine()).equals("0 0") == false){
        // input
        String[] input = str.split(" ");
        int n = Integer.parseInt(input[0]);
        int x = Integer.parseInt(input[1]);
        if(n < 3 || n > 100) return;

        int count = 0;
        // finish
        if(n == 0 && x == 0) break;
        // check
        for(int i = 1; i <= n; i++){
          for(int j = (i + 1); (i + j) < x; j++){
            int k = x - i - j;
            if(k > j && k <= n) count++;
          }
        }
        sb.append(count + "\n");
      }
      // output
      System.out.print(sb);
    }catch(Exception e){
      System.out.println(e);
    }
  } try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringBuilder sb = new StringBuilder();
      String str = "";

      while((str = br.readLine()).equals("0 0") == false){
        // input
        String[] input = str.split(" ");
        int n = Integer.parseInt(input[0]);
        int x = Integer.parseInt(input[1]);
        if(n < 3 || n > 100) return;

        int count = 0;
        // finish
        if(n == 0 && x == 0) break;
        // check
        for(int i = 1; i <= n; i++){
          for(int j = (i + 1); (i + j) < x; j++){
            int k = x - i - j;
            if(k > j && k <= n) count++;
          }
        }
        sb.append(count + "\n");
      }
      // output
      System.out.print(sb);
    }catch(Exception e){
      System.out.println(e);
    } catch(Exception e){
      System.out.println(e);
    } Exception e {
      System.out.println(e);
    } System.out.println(e) System.out.println System.out System System.out e {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringBuilder sb = new StringBuilder();
      String str = "";

      while((str = br.readLine()).equals("0 0") == false){
        // input
        String[] input = str.split(" ");
        int n = Integer.parseInt(input[0]);
        int x = Integer.parseInt(input[1]);
        if(n < 3 || n > 100) return;

        int count = 0;
        // finish
        if(n == 0 && x == 0) break;
        // check
        for(int i = 1; i <= n; i++){
          for(int j = (i + 1); (i + j) < x; j++){
            int k = x - i - j;
            if(k > j && k <= n) count++;
          }
        }
        sb.append(count + "\n");
      }
      // output
      System.out.print(sb);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringBuilder sb = new StringBuilder(); sb new StringBuilder() String str = ""; str "" while((str = br.readLine()).equals("0 0") == false){
        // input
        String[] input = str.split(" ");
        int n = Integer.parseInt(input[0]);
        int x = Integer.parseInt(input[1]);
        if(n < 3 || n > 100) return;

        int count = 0;
        // finish
        if(n == 0 && x == 0) break;
        // check
        for(int i = 1; i <= n; i++){
          for(int j = (i + 1); (i + j) < x; j++){
            int k = x - i - j;
            if(k > j && k <= n) count++;
          }
        }
        sb.append(count + "\n");
      } (str = br.readLine()).equals("0 0") == false (str = br.readLine()).equals("0 0") (str = br.readLine()).equals (str = br.readLine()) str br.readLine() br.readLine br "0 0" false {
        // input
        String[] input = str.split(" ");
        int n = Integer.parseInt(input[0]);
        int x = Integer.parseInt(input[1]);
        if(n < 3 || n > 100) return;

        int count = 0;
        // finish
        if(n == 0 && x == 0) break;
        // check
        for(int i = 1; i <= n; i++){
          for(int j = (i + 1); (i + j) < x; j++){
            int k = x - i - j;
            if(k > j && k <= n) count++;
          }
        }
        sb.append(count + "\n");
      } String[] input = str.split(" "); input str.split(" ") str.split str " " int n = Integer.parseInt(input[0]); n Integer.parseInt(input[0]) Integer.parseInt Integer input[0] input 0 int x = Integer.parseInt(input[1]); x Integer.parseInt(input[1]) Integer.parseInt Integer input[1] input 1 if(n < 3 || n > 100) return; n < 3 || n > 100 n < 3 n 3 n > 100 n 100 return; int count = 0; count 0 if(n == 0 && x == 0) break; n == 0 && x == 0 n == 0 n 0 x == 0 x 0 break; for(int i = 1; i <= n; i++){
          for(int j = (i + 1); (i + j) < x; j++){
            int k = x - i - j;
            if(k > j && k <= n) count++;
          }
        } int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
          for(int j = (i + 1); (i + j) < x; j++){
            int k = x - i - j;
            if(k > j && k <= n) count++;
          }
        } {
          for(int j = (i + 1); (i + j) < x; j++){
            int k = x - i - j;
            if(k > j && k <= n) count++;
          }
        } for(int j = (i + 1); (i + j) < x; j++){
            int k = x - i - j;
            if(k > j && k <= n) count++;
          } int j = (i + 1); int j = (i + 1); j (i + 1) i 1 (i + j) < x (i + j) i j x j++ j++ j {
            int k = x - i - j;
            if(k > j && k <= n) count++;
          } {
            int k = x - i - j;
            if(k > j && k <= n) count++;
          } int k = x - i - j; k x - i - j x - i - j x i j if(k > j && k <= n) count++; k > j && k <= n k > j k j k <= n k n count++ count sb.append(count + "\n") sb.append sb count + "\n" count "\n" System.out.print(sb) System.out.print System.out System System.out sb String[] args args
/* ITP1_7_B */
import java.io.*;

class Main
{
  public static void main(String[] args)
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringBuilder sb = new StringBuilder();
      String str = "";

      while((str = br.readLine()).equals("0 0") == false){
        // input
        String[] input = str.split(" ");
        int n = Integer.parseInt(input[0]);
        int x = Integer.parseInt(input[1]);
        if(n < 3 || n > 100) return;

        int count = 0;
        // finish
        if(n == 0 && x == 0) break;
        // check
        for(int i = 1; i <= n; i++){
          for(int j = (i + 1); (i + j) < x; j++){
            int k = x - i - j;
            if(k > j && k <= n) count++;
          }
        }
        sb.append(count + "\n");
      }
      // output
      System.out.print(sb);
    }catch(Exception e){
      System.out.println(e);
    }
  }
}