import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int K = Integer.parseInt(sc.next());
        int S = Integer.parseInt(sc.next());
        int count = 0;
        for(int x=0; x <= K &&  x <= S; x++){
            for(int y=0; y <= K && y <= S; y++){
                if((x + y) <= S &&  S - (x + y) <= K){
                    count++;
                }
            }
        }
        System.out.print(count);
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int K = Integer.parseInt(sc.next());
        int S = Integer.parseInt(sc.next());
        int count = 0;
        for(int x=0; x <= K &&  x <= S; x++){
            for(int y=0; y <= K && y <= S; y++){
                if((x + y) <= S &&  S - (x + y) <= K){
                    count++;
                }
            }
        }
        System.out.print(count);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int K = Integer.parseInt(sc.next());
        int S = Integer.parseInt(sc.next());
        int count = 0;
        for(int x=0; x <= K &&  x <= S; x++){
            for(int y=0; y <= K && y <= S; y++){
                if((x + y) <= S &&  S - (x + y) <= K){
                    count++;
                }
            }
        }
        System.out.print(count);
    } main {
        Scanner sc = new Scanner(System.in);
        int K = Integer.parseInt(sc.next());
        int S = Integer.parseInt(sc.next());
        int count = 0;
        for(int x=0; x <= K &&  x <= S; x++){
            for(int y=0; y <= K && y <= S; y++){
                if((x + y) <= S &&  S - (x + y) <= K){
                    count++;
                }
            }
        }
        System.out.print(count);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int K = Integer.parseInt(sc.next()); K Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int S = Integer.parseInt(sc.next()); S Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int count = 0; count 0 for(int x=0; x <= K &&  x <= S; x++){
            for(int y=0; y <= K && y <= S; y++){
                if((x + y) <= S &&  S - (x + y) <= K){
                    count++;
                }
            }
        } int x=0; int x=0; x 0 x <= K &&  x <= S x <= K x K x <= S x S x++ x++ x {
            for(int y=0; y <= K && y <= S; y++){
                if((x + y) <= S &&  S - (x + y) <= K){
                    count++;
                }
            }
        } {
            for(int y=0; y <= K && y <= S; y++){
                if((x + y) <= S &&  S - (x + y) <= K){
                    count++;
                }
            }
        } for(int y=0; y <= K && y <= S; y++){
                if((x + y) <= S &&  S - (x + y) <= K){
                    count++;
                }
            } int y=0; int y=0; y 0 y <= K && y <= S y <= K y K y <= S y S y++ y++ y {
                if((x + y) <= S &&  S - (x + y) <= K){
                    count++;
                }
            } {
                if((x + y) <= S &&  S - (x + y) <= K){
                    count++;
                }
            } if((x + y) <= S &&  S - (x + y) <= K){
                    count++;
                } (x + y) <= S &&  S - (x + y) <= K (x + y) <= S (x + y) x y S S - (x + y) <= K S - (x + y) S (x + y) x y K {
                    count++;
                } count++ count System.out.print(count) System.out.print 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 = Integer.parseInt(sc.next());
        int S = Integer.parseInt(sc.next());
        int count = 0;
        for(int x=0; x <= K &&  x <= S; x++){
            for(int y=0; y <= K && y <= S; y++){
                if((x + y) <= S &&  S - (x + y) <= K){
                    count++;
                }
            }
        }
        System.out.print(count);
    }
} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int K = Integer.parseInt(sc.next());
        int S = Integer.parseInt(sc.next());
        int count = 0;
        for(int x=0; x <= K &&  x <= S; x++){
            for(int y=0; y <= K && y <= S; y++){
                if((x + y) <= S &&  S - (x + y) <= K){
                    count++;
                }
            }
        }
        System.out.print(count);
    }
} Main
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int K = Integer.parseInt(sc.next());
        int S = Integer.parseInt(sc.next());
        int count = 0;
        for(int x=0; x <= K &&  x <= S; x++){
            for(int y=0; y <= K && y <= S; y++){
                if((x + y) <= S &&  S - (x + y) <= K){
                    count++;
                }
            }
        }
        System.out.print(count);
    }
}