import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int count = 0;
            
            for(int X=0; X<=K; X++){
                for(int Y=0; Y<=K; Y++){
                    int Z = S-X-Y;
                    if(0<=Z && Z<=K){
                        count++;
                    }
                }
            }
            
            System.out.println(count); 
    } 
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int count = 0;
            
            for(int X=0; X<=K; X++){
                for(int Y=0; Y<=K; Y++){
                    int Z = S-X-Y;
                    if(0<=Z && Z<=K){
                        count++;
                    }
                }
            }
            
            System.out.println(count); 
    } 
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int count = 0;
            
            for(int X=0; X<=K; X++){
                for(int Y=0; Y<=K; Y++){
                    int Z = S-X-Y;
                    if(0<=Z && Z<=K){
                        count++;
                    }
                }
            }
            
            System.out.println(count); 
    } main {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int count = 0;
            
            for(int X=0; X<=K; X++){
                for(int Y=0; Y<=K; Y++){
                    int Z = S-X-Y;
                    if(0<=Z && Z<=K){
                        count++;
                    }
                }
            }
            
            System.out.println(count); 
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc int S = sc.nextInt(); S sc.nextInt() sc.nextInt sc int count = 0; count 0 for(int X=0; X<=K; X++){
                for(int Y=0; Y<=K; Y++){
                    int Z = S-X-Y;
                    if(0<=Z && Z<=K){
                        count++;
                    }
                }
            } int X=0; int X=0; X 0 X<=K X K X++ X++ X {
                for(int Y=0; Y<=K; Y++){
                    int Z = S-X-Y;
                    if(0<=Z && Z<=K){
                        count++;
                    }
                }
            } {
                for(int Y=0; Y<=K; Y++){
                    int Z = S-X-Y;
                    if(0<=Z && Z<=K){
                        count++;
                    }
                }
            } for(int Y=0; Y<=K; Y++){
                    int Z = S-X-Y;
                    if(0<=Z && Z<=K){
                        count++;
                    }
                } int Y=0; int Y=0; Y 0 Y<=K Y K Y++ Y++ Y {
                    int Z = S-X-Y;
                    if(0<=Z && Z<=K){
                        count++;
                    }
                } {
                    int Z = S-X-Y;
                    if(0<=Z && Z<=K){
                        count++;
                    }
                } int Z = S-X-Y; Z S-X-Y S-X-Y S X Y if(0<=Z && Z<=K){
                        count++;
                    } 0<=Z && Z<=K 0<=Z 0 Z Z<=K Z K {
                        count++;
                    } count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int count = 0;
            
            for(int X=0; X<=K; X++){
                for(int Y=0; Y<=K; Y++){
                    int Z = S-X-Y;
                    if(0<=Z && Z<=K){
                        count++;
                    }
                }
            }
            
            System.out.println(count); 
    } 
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int count = 0;
            
            for(int X=0; X<=K; X++){
                for(int Y=0; Y<=K; Y++){
                    int Z = S-X-Y;
                    if(0<=Z && Z<=K){
                        count++;
                    }
                }
            }
            
            System.out.println(count); 
    } 
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int count = 0;
            
            for(int X=0; X<=K; X++){
                for(int Y=0; Y<=K; Y++){
                    int Z = S-X-Y;
                    if(0<=Z && Z<=K){
                        count++;
                    }
                }
            }
            
            System.out.println(count); 
    } 
}
