import java.util.*;
import java.io.*;
 
 
public class Main{
 public static void  main(String[] args)throws IOException{
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  String str = br.readLine();
                     
                    while(str !=null){
                        String[] temp = str.split("\\s");
                        int Enum = Integer.parseInt(temp[0]);
                        int target = Integer.parseInt(temp[1]);
 
                        if(Enum ==0 && target ==0){
                            break;
                        }
                         
                        int count =0;
                        for(int i =1;i<=Enum-2;i++){
                            for(int j=i+1;j<=Enum-1;j++){
                                for(int k=j+1;k<=Enum;k++){
                                    int total = 0;
                                    total = i + j + k;
                                    if(total == target){
                                        count++;
                                    }
                                }
                            }                    
                        }
                        System.out.println(count);
                        str = br.readLine();
 
                    } 
 }
} import java.util.*; util.* java import java.io.*; io.* java public class Main{
 public static void  main(String[] args)throws IOException{
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  String str = br.readLine();
                     
                    while(str !=null){
                        String[] temp = str.split("\\s");
                        int Enum = Integer.parseInt(temp[0]);
                        int target = Integer.parseInt(temp[1]);
 
                        if(Enum ==0 && target ==0){
                            break;
                        }
                         
                        int count =0;
                        for(int i =1;i<=Enum-2;i++){
                            for(int j=i+1;j<=Enum-1;j++){
                                for(int k=j+1;k<=Enum;k++){
                                    int total = 0;
                                    total = i + j + k;
                                    if(total == target){
                                        count++;
                                    }
                                }
                            }                    
                        }
                        System.out.println(count);
                        str = br.readLine();
 
                    } 
 }
} Main public static void  main(String[] args)throws IOException{
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  String str = br.readLine();
                     
                    while(str !=null){
                        String[] temp = str.split("\\s");
                        int Enum = Integer.parseInt(temp[0]);
                        int target = Integer.parseInt(temp[1]);
 
                        if(Enum ==0 && target ==0){
                            break;
                        }
                         
                        int count =0;
                        for(int i =1;i<=Enum-2;i++){
                            for(int j=i+1;j<=Enum-1;j++){
                                for(int k=j+1;k<=Enum;k++){
                                    int total = 0;
                                    total = i + j + k;
                                    if(total == target){
                                        count++;
                                    }
                                }
                            }                    
                        }
                        System.out.println(count);
                        str = br.readLine();
 
                    } 
 } main {
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  String str = br.readLine();
                     
                    while(str !=null){
                        String[] temp = str.split("\\s");
                        int Enum = Integer.parseInt(temp[0]);
                        int target = Integer.parseInt(temp[1]);
 
                        if(Enum ==0 && target ==0){
                            break;
                        }
                         
                        int count =0;
                        for(int i =1;i<=Enum-2;i++){
                            for(int j=i+1;j<=Enum-1;j++){
                                for(int k=j+1;k<=Enum;k++){
                                    int total = 0;
                                    total = i + j + k;
                                    if(total == target){
                                        count++;
                                    }
                                }
                            }                    
                        }
                        System.out.println(count);
                        str = br.readLine();
 
                    } 
 } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str = br.readLine(); str br.readLine() br.readLine br while(str !=null){
                        String[] temp = str.split("\\s");
                        int Enum = Integer.parseInt(temp[0]);
                        int target = Integer.parseInt(temp[1]);
 
                        if(Enum ==0 && target ==0){
                            break;
                        }
                         
                        int count =0;
                        for(int i =1;i<=Enum-2;i++){
                            for(int j=i+1;j<=Enum-1;j++){
                                for(int k=j+1;k<=Enum;k++){
                                    int total = 0;
                                    total = i + j + k;
                                    if(total == target){
                                        count++;
                                    }
                                }
                            }                    
                        }
                        System.out.println(count);
                        str = br.readLine();
 
                    } str !=null str null {
                        String[] temp = str.split("\\s");
                        int Enum = Integer.parseInt(temp[0]);
                        int target = Integer.parseInt(temp[1]);
 
                        if(Enum ==0 && target ==0){
                            break;
                        }
                         
                        int count =0;
                        for(int i =1;i<=Enum-2;i++){
                            for(int j=i+1;j<=Enum-1;j++){
                                for(int k=j+1;k<=Enum;k++){
                                    int total = 0;
                                    total = i + j + k;
                                    if(total == target){
                                        count++;
                                    }
                                }
                            }                    
                        }
                        System.out.println(count);
                        str = br.readLine();
 
                    } String[] temp = str.split("\\s"); temp str.split("\\s") str.split str "\\s" int Enum = Integer.parseInt(temp[0]); Enum Integer.parseInt(temp[0]) Integer.parseInt Integer temp[0] temp 0 int target = Integer.parseInt(temp[1]); target Integer.parseInt(temp[1]) Integer.parseInt Integer temp[1] temp 1 if(Enum ==0 && target ==0){
                            break;
                        } Enum ==0 && target ==0 Enum ==0 Enum 0 target ==0 target 0 {
                            break;
                        } break; int count =0; count 0 for(int i =1;i<=Enum-2;i++){
                            for(int j=i+1;j<=Enum-1;j++){
                                for(int k=j+1;k<=Enum;k++){
                                    int total = 0;
                                    total = i + j + k;
                                    if(total == target){
                                        count++;
                                    }
                                }
                            }                    
                        } int i =1; int i =1; i 1 i<=Enum-2 i Enum-2 Enum 2 i++ i++ i {
                            for(int j=i+1;j<=Enum-1;j++){
                                for(int k=j+1;k<=Enum;k++){
                                    int total = 0;
                                    total = i + j + k;
                                    if(total == target){
                                        count++;
                                    }
                                }
                            }                    
                        } {
                            for(int j=i+1;j<=Enum-1;j++){
                                for(int k=j+1;k<=Enum;k++){
                                    int total = 0;
                                    total = i + j + k;
                                    if(total == target){
                                        count++;
                                    }
                                }
                            }                    
                        } for(int j=i+1;j<=Enum-1;j++){
                                for(int k=j+1;k<=Enum;k++){
                                    int total = 0;
                                    total = i + j + k;
                                    if(total == target){
                                        count++;
                                    }
                                }
                            } int j=i+1; int j=i+1; j i+1 i 1 j<=Enum-1 j Enum-1 Enum 1 j++ j++ j {
                                for(int k=j+1;k<=Enum;k++){
                                    int total = 0;
                                    total = i + j + k;
                                    if(total == target){
                                        count++;
                                    }
                                }
                            } {
                                for(int k=j+1;k<=Enum;k++){
                                    int total = 0;
                                    total = i + j + k;
                                    if(total == target){
                                        count++;
                                    }
                                }
                            } for(int k=j+1;k<=Enum;k++){
                                    int total = 0;
                                    total = i + j + k;
                                    if(total == target){
                                        count++;
                                    }
                                } int k=j+1; int k=j+1; k j+1 j 1 k<=Enum k Enum k++ k++ k {
                                    int total = 0;
                                    total = i + j + k;
                                    if(total == target){
                                        count++;
                                    }
                                } {
                                    int total = 0;
                                    total = i + j + k;
                                    if(total == target){
                                        count++;
                                    }
                                } int total = 0; total 0 total = i + j + k total i + j + k i + j + k i j k if(total == target){
                                        count++;
                                    } total == target total target {
                                        count++;
                                    } count++ count System.out.println(count) System.out.println System.out System System.out count str = br.readLine() str br.readLine() br.readLine br String[] args args public class Main{
 public static void  main(String[] args)throws IOException{
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  String str = br.readLine();
                     
                    while(str !=null){
                        String[] temp = str.split("\\s");
                        int Enum = Integer.parseInt(temp[0]);
                        int target = Integer.parseInt(temp[1]);
 
                        if(Enum ==0 && target ==0){
                            break;
                        }
                         
                        int count =0;
                        for(int i =1;i<=Enum-2;i++){
                            for(int j=i+1;j<=Enum-1;j++){
                                for(int k=j+1;k<=Enum;k++){
                                    int total = 0;
                                    total = i + j + k;
                                    if(total == target){
                                        count++;
                                    }
                                }
                            }                    
                        }
                        System.out.println(count);
                        str = br.readLine();
 
                    } 
 }
} public class Main{
 public static void  main(String[] args)throws IOException{
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  String str = br.readLine();
                     
                    while(str !=null){
                        String[] temp = str.split("\\s");
                        int Enum = Integer.parseInt(temp[0]);
                        int target = Integer.parseInt(temp[1]);
 
                        if(Enum ==0 && target ==0){
                            break;
                        }
                         
                        int count =0;
                        for(int i =1;i<=Enum-2;i++){
                            for(int j=i+1;j<=Enum-1;j++){
                                for(int k=j+1;k<=Enum;k++){
                                    int total = 0;
                                    total = i + j + k;
                                    if(total == target){
                                        count++;
                                    }
                                }
                            }                    
                        }
                        System.out.println(count);
                        str = br.readLine();
 
                    } 
 }
} Main
import java.util.*;
import java.io.*;
 
 
public class Main{
 public static void  main(String[] args)throws IOException{
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  String str = br.readLine();
                     
                    while(str !=null){
                        String[] temp = str.split("\\s");
                        int Enum = Integer.parseInt(temp[0]);
                        int target = Integer.parseInt(temp[1]);
 
                        if(Enum ==0 && target ==0){
                            break;
                        }
                         
                        int count =0;
                        for(int i =1;i<=Enum-2;i++){
                            for(int j=i+1;j<=Enum-1;j++){
                                for(int k=j+1;k<=Enum;k++){
                                    int total = 0;
                                    total = i + j + k;
                                    if(total == target){
                                        count++;
                                    }
                                }
                            }                    
                        }
                        System.out.println(count);
                        str = br.readLine();
 
                    } 
 }
}