
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        List<Set> pie = new ArrayList<>();
        int count = 0;
        
        while(true){
          pie.add(new Set (sc.nextInt(),sc.nextInt()));
          
          if(pie.get(count).x == 0 && pie.get(count).y == 0) break;
              
          count++;      
        }
        
        for(int i=0; i < pie.size()-1; i++){
            int root = 0;
            for(int x=1; x<=pie.get(i).x; x++){
              for(int y=1; y<=pie.get(i).x; y++){
                for(int z=1; z<=pie.get(i).x; z++){
                    if(x != y && x != z && y != z){
                        if(x <= pie.get(i).x || y <= pie.get(i).x || z <= pie.get(i).x ){
                            if(x+y+z == pie.get(i).y){
                                //System.out.println((x)+" "+(y)+" "+(z));
                                root ++;
                            }
                        }
                    }
                    
                }
              } 
            }
            
            System.out.println(root / 6);
            //System.out.println(pie.get(0).x);
        }
    }
}

class Set{
    int x = 0;
    int y = 0;
    
    Set(int x, int y){
       this.x = x;
       this.y =y;
    }
}
 import java.util.ArrayList; ArrayList java.util import java.util.Iterator; Iterator java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        List<Set> pie = new ArrayList<>();
        int count = 0;
        
        while(true){
          pie.add(new Set (sc.nextInt(),sc.nextInt()));
          
          if(pie.get(count).x == 0 && pie.get(count).y == 0) break;
              
          count++;      
        }
        
        for(int i=0; i < pie.size()-1; i++){
            int root = 0;
            for(int x=1; x<=pie.get(i).x; x++){
              for(int y=1; y<=pie.get(i).x; y++){
                for(int z=1; z<=pie.get(i).x; z++){
                    if(x != y && x != z && y != z){
                        if(x <= pie.get(i).x || y <= pie.get(i).x || z <= pie.get(i).x ){
                            if(x+y+z == pie.get(i).y){
                                //System.out.println((x)+" "+(y)+" "+(z));
                                root ++;
                            }
                        }
                    }
                    
                }
              } 
            }
            
            System.out.println(root / 6);
            //System.out.println(pie.get(0).x);
        }
    }
} Main public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        List<Set> pie = new ArrayList<>();
        int count = 0;
        
        while(true){
          pie.add(new Set (sc.nextInt(),sc.nextInt()));
          
          if(pie.get(count).x == 0 && pie.get(count).y == 0) break;
              
          count++;      
        }
        
        for(int i=0; i < pie.size()-1; i++){
            int root = 0;
            for(int x=1; x<=pie.get(i).x; x++){
              for(int y=1; y<=pie.get(i).x; y++){
                for(int z=1; z<=pie.get(i).x; z++){
                    if(x != y && x != z && y != z){
                        if(x <= pie.get(i).x || y <= pie.get(i).x || z <= pie.get(i).x ){
                            if(x+y+z == pie.get(i).y){
                                //System.out.println((x)+" "+(y)+" "+(z));
                                root ++;
                            }
                        }
                    }
                    
                }
              } 
            }
            
            System.out.println(root / 6);
            //System.out.println(pie.get(0).x);
        }
    } main {
        
        Scanner sc = new Scanner(System.in);
        List<Set> pie = new ArrayList<>();
        int count = 0;
        
        while(true){
          pie.add(new Set (sc.nextInt(),sc.nextInt()));
          
          if(pie.get(count).x == 0 && pie.get(count).y == 0) break;
              
          count++;      
        }
        
        for(int i=0; i < pie.size()-1; i++){
            int root = 0;
            for(int x=1; x<=pie.get(i).x; x++){
              for(int y=1; y<=pie.get(i).x; y++){
                for(int z=1; z<=pie.get(i).x; z++){
                    if(x != y && x != z && y != z){
                        if(x <= pie.get(i).x || y <= pie.get(i).x || z <= pie.get(i).x ){
                            if(x+y+z == pie.get(i).y){
                                //System.out.println((x)+" "+(y)+" "+(z));
                                root ++;
                            }
                        }
                    }
                    
                }
              } 
            }
            
            System.out.println(root / 6);
            //System.out.println(pie.get(0).x);
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) List<Set> pie = new ArrayList<>(); pie new ArrayList<>() int count = 0; count 0 while(true){
          pie.add(new Set (sc.nextInt(),sc.nextInt()));
          
          if(pie.get(count).x == 0 && pie.get(count).y == 0) break;
              
          count++;      
        } true {
          pie.add(new Set (sc.nextInt(),sc.nextInt()));
          
          if(pie.get(count).x == 0 && pie.get(count).y == 0) break;
              
          count++;      
        } pie.add(new Set (sc.nextInt(),sc.nextInt())) pie.add pie new Set (sc.nextInt(),sc.nextInt()) if(pie.get(count).x == 0 && pie.get(count).y == 0) break; pie.get(count).x == 0 && pie.get(count).y == 0 pie.get(count).x == 0 pie.get(count).x pie.get(count) pie.get pie count pie.get(count).x 0 pie.get(count).y == 0 pie.get(count).y pie.get(count) pie.get pie count pie.get(count).y 0 break; count++ count for(int i=0; i < pie.size()-1; i++){
            int root = 0;
            for(int x=1; x<=pie.get(i).x; x++){
              for(int y=1; y<=pie.get(i).x; y++){
                for(int z=1; z<=pie.get(i).x; z++){
                    if(x != y && x != z && y != z){
                        if(x <= pie.get(i).x || y <= pie.get(i).x || z <= pie.get(i).x ){
                            if(x+y+z == pie.get(i).y){
                                //System.out.println((x)+" "+(y)+" "+(z));
                                root ++;
                            }
                        }
                    }
                    
                }
              } 
            }
            
            System.out.println(root / 6);
            //System.out.println(pie.get(0).x);
        } int i=0; int i=0; i 0 i < pie.size()-1 i pie.size()-1 pie.size() pie.size pie 1 i++ i++ i {
            int root = 0;
            for(int x=1; x<=pie.get(i).x; x++){
              for(int y=1; y<=pie.get(i).x; y++){
                for(int z=1; z<=pie.get(i).x; z++){
                    if(x != y && x != z && y != z){
                        if(x <= pie.get(i).x || y <= pie.get(i).x || z <= pie.get(i).x ){
                            if(x+y+z == pie.get(i).y){
                                //System.out.println((x)+" "+(y)+" "+(z));
                                root ++;
                            }
                        }
                    }
                    
                }
              } 
            }
            
            System.out.println(root / 6);
            //System.out.println(pie.get(0).x);
        } {
            int root = 0;
            for(int x=1; x<=pie.get(i).x; x++){
              for(int y=1; y<=pie.get(i).x; y++){
                for(int z=1; z<=pie.get(i).x; z++){
                    if(x != y && x != z && y != z){
                        if(x <= pie.get(i).x || y <= pie.get(i).x || z <= pie.get(i).x ){
                            if(x+y+z == pie.get(i).y){
                                //System.out.println((x)+" "+(y)+" "+(z));
                                root ++;
                            }
                        }
                    }
                    
                }
              } 
            }
            
            System.out.println(root / 6);
            //System.out.println(pie.get(0).x);
        } int root = 0; root 0 for(int x=1; x<=pie.get(i).x; x++){
              for(int y=1; y<=pie.get(i).x; y++){
                for(int z=1; z<=pie.get(i).x; z++){
                    if(x != y && x != z && y != z){
                        if(x <= pie.get(i).x || y <= pie.get(i).x || z <= pie.get(i).x ){
                            if(x+y+z == pie.get(i).y){
                                //System.out.println((x)+" "+(y)+" "+(z));
                                root ++;
                            }
                        }
                    }
                    
                }
              } 
            } int x=1; int x=1; x 1 x<=pie.get(i).x x pie.get(i).x pie.get(i) pie.get pie i pie.get(i).x x++ x++ x {
              for(int y=1; y<=pie.get(i).x; y++){
                for(int z=1; z<=pie.get(i).x; z++){
                    if(x != y && x != z && y != z){
                        if(x <= pie.get(i).x || y <= pie.get(i).x || z <= pie.get(i).x ){
                            if(x+y+z == pie.get(i).y){
                                //System.out.println((x)+" "+(y)+" "+(z));
                                root ++;
                            }
                        }
                    }
                    
                }
              } 
            } {
              for(int y=1; y<=pie.get(i).x; y++){
                for(int z=1; z<=pie.get(i).x; z++){
                    if(x != y && x != z && y != z){
                        if(x <= pie.get(i).x || y <= pie.get(i).x || z <= pie.get(i).x ){
                            if(x+y+z == pie.get(i).y){
                                //System.out.println((x)+" "+(y)+" "+(z));
                                root ++;
                            }
                        }
                    }
                    
                }
              } 
            } for(int y=1; y<=pie.get(i).x; y++){
                for(int z=1; z<=pie.get(i).x; z++){
                    if(x != y && x != z && y != z){
                        if(x <= pie.get(i).x || y <= pie.get(i).x || z <= pie.get(i).x ){
                            if(x+y+z == pie.get(i).y){
                                //System.out.println((x)+" "+(y)+" "+(z));
                                root ++;
                            }
                        }
                    }
                    
                }
              } int y=1; int y=1; y 1 y<=pie.get(i).x y pie.get(i).x pie.get(i) pie.get pie i pie.get(i).x y++ y++ y {
                for(int z=1; z<=pie.get(i).x; z++){
                    if(x != y && x != z && y != z){
                        if(x <= pie.get(i).x || y <= pie.get(i).x || z <= pie.get(i).x ){
                            if(x+y+z == pie.get(i).y){
                                //System.out.println((x)+" "+(y)+" "+(z));
                                root ++;
                            }
                        }
                    }
                    
                }
              } {
                for(int z=1; z<=pie.get(i).x; z++){
                    if(x != y && x != z && y != z){
                        if(x <= pie.get(i).x || y <= pie.get(i).x || z <= pie.get(i).x ){
                            if(x+y+z == pie.get(i).y){
                                //System.out.println((x)+" "+(y)+" "+(z));
                                root ++;
                            }
                        }
                    }
                    
                }
              } for(int z=1; z<=pie.get(i).x; z++){
                    if(x != y && x != z && y != z){
                        if(x <= pie.get(i).x || y <= pie.get(i).x || z <= pie.get(i).x ){
                            if(x+y+z == pie.get(i).y){
                                //System.out.println((x)+" "+(y)+" "+(z));
                                root ++;
                            }
                        }
                    }
                    
                } int z=1; int z=1; z 1 z<=pie.get(i).x z pie.get(i).x pie.get(i) pie.get pie i pie.get(i).x z++ z++ z {
                    if(x != y && x != z && y != z){
                        if(x <= pie.get(i).x || y <= pie.get(i).x || z <= pie.get(i).x ){
                            if(x+y+z == pie.get(i).y){
                                //System.out.println((x)+" "+(y)+" "+(z));
                                root ++;
                            }
                        }
                    }
                    
                } {
                    if(x != y && x != z && y != z){
                        if(x <= pie.get(i).x || y <= pie.get(i).x || z <= pie.get(i).x ){
                            if(x+y+z == pie.get(i).y){
                                //System.out.println((x)+" "+(y)+" "+(z));
                                root ++;
                            }
                        }
                    }
                    
                } if(x != y && x != z && y != z){
                        if(x <= pie.get(i).x || y <= pie.get(i).x || z <= pie.get(i).x ){
                            if(x+y+z == pie.get(i).y){
                                //System.out.println((x)+" "+(y)+" "+(z));
                                root ++;
                            }
                        }
                    } x != y && x != z && y != z x != y && x != z && y != z x != y x y x != z x z y != z y z {
                        if(x <= pie.get(i).x || y <= pie.get(i).x || z <= pie.get(i).x ){
                            if(x+y+z == pie.get(i).y){
                                //System.out.println((x)+" "+(y)+" "+(z));
                                root ++;
                            }
                        }
                    } if(x <= pie.get(i).x || y <= pie.get(i).x || z <= pie.get(i).x ){
                            if(x+y+z == pie.get(i).y){
                                //System.out.println((x)+" "+(y)+" "+(z));
                                root ++;
                            }
                        } x <= pie.get(i).x || y <= pie.get(i).x || z <= pie.get(i).x x <= pie.get(i).x || y <= pie.get(i).x || z <= pie.get(i).x x <= pie.get(i).x x pie.get(i).x pie.get(i) pie.get pie i pie.get(i).x y <= pie.get(i).x y pie.get(i).x pie.get(i) pie.get pie i pie.get(i).x z <= pie.get(i).x z pie.get(i).x pie.get(i) pie.get pie i pie.get(i).x {
                            if(x+y+z == pie.get(i).y){
                                //System.out.println((x)+" "+(y)+" "+(z));
                                root ++;
                            }
                        } if(x+y+z == pie.get(i).y){
                                //System.out.println((x)+" "+(y)+" "+(z));
                                root ++;
                            } x+y+z == pie.get(i).y x+y+z x+y+z x y z pie.get(i).y pie.get(i) pie.get pie i pie.get(i).y {
                                //System.out.println((x)+" "+(y)+" "+(z));
                                root ++;
                            } root ++ root System.out.println(root / 6) System.out.println System.out System System.out root / 6 root 6 String[] args args class Set{
    int x = 0;
    int y = 0;
    
    Set(int x, int y){
       this.x = x;
       this.y =y;
    }
} Set int x = 0; x 0 int y = 0; y 0 Set(int x, int y){
       this.x = x;
       this.y =y;
    } Set {
       this.x = x;
       this.y =y;
    } this.x = x this.x this this.x x this.y =y this.y this this.y y int x x int y y public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        List<Set> pie = new ArrayList<>();
        int count = 0;
        
        while(true){
          pie.add(new Set (sc.nextInt(),sc.nextInt()));
          
          if(pie.get(count).x == 0 && pie.get(count).y == 0) break;
              
          count++;      
        }
        
        for(int i=0; i < pie.size()-1; i++){
            int root = 0;
            for(int x=1; x<=pie.get(i).x; x++){
              for(int y=1; y<=pie.get(i).x; y++){
                for(int z=1; z<=pie.get(i).x; z++){
                    if(x != y && x != z && y != z){
                        if(x <= pie.get(i).x || y <= pie.get(i).x || z <= pie.get(i).x ){
                            if(x+y+z == pie.get(i).y){
                                //System.out.println((x)+" "+(y)+" "+(z));
                                root ++;
                            }
                        }
                    }
                    
                }
              } 
            }
            
            System.out.println(root / 6);
            //System.out.println(pie.get(0).x);
        }
    }
} public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        List<Set> pie = new ArrayList<>();
        int count = 0;
        
        while(true){
          pie.add(new Set (sc.nextInt(),sc.nextInt()));
          
          if(pie.get(count).x == 0 && pie.get(count).y == 0) break;
              
          count++;      
        }
        
        for(int i=0; i < pie.size()-1; i++){
            int root = 0;
            for(int x=1; x<=pie.get(i).x; x++){
              for(int y=1; y<=pie.get(i).x; y++){
                for(int z=1; z<=pie.get(i).x; z++){
                    if(x != y && x != z && y != z){
                        if(x <= pie.get(i).x || y <= pie.get(i).x || z <= pie.get(i).x ){
                            if(x+y+z == pie.get(i).y){
                                //System.out.println((x)+" "+(y)+" "+(z));
                                root ++;
                            }
                        }
                    }
                    
                }
              } 
            }
            
            System.out.println(root / 6);
            //System.out.println(pie.get(0).x);
        }
    }
} Main

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        List<Set> pie = new ArrayList<>();
        int count = 0;
        
        while(true){
          pie.add(new Set (sc.nextInt(),sc.nextInt()));
          
          if(pie.get(count).x == 0 && pie.get(count).y == 0) break;
              
          count++;      
        }
        
        for(int i=0; i < pie.size()-1; i++){
            int root = 0;
            for(int x=1; x<=pie.get(i).x; x++){
              for(int y=1; y<=pie.get(i).x; y++){
                for(int z=1; z<=pie.get(i).x; z++){
                    if(x != y && x != z && y != z){
                        if(x <= pie.get(i).x || y <= pie.get(i).x || z <= pie.get(i).x ){
                            if(x+y+z == pie.get(i).y){
                                //System.out.println((x)+" "+(y)+" "+(z));
                                root ++;
                            }
                        }
                    }
                    
                }
              } 
            }
            
            System.out.println(root / 6);
            //System.out.println(pie.get(0).x);
        }
    }
}

class Set{
    int x = 0;
    int y = 0;
    
    Set(int x, int y){
       this.x = x;
       this.y =y;
    }
}

