
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner Input = new Scanner(System.in);
        int K = Input.nextInt();
        int S = Input.nextInt();
        int Counter = 0;
        for (int X = 0; X <= K; X++) {
            for (int Y = 0; Y <= K; Y++) {

                if (0 <= S - (X + Y) && S - (X + Y) <= K) {
                    Counter++;
                }
            }
        }
        System.out.println(Counter);
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner Input = new Scanner(System.in);
        int K = Input.nextInt();
        int S = Input.nextInt();
        int Counter = 0;
        for (int X = 0; X <= K; X++) {
            for (int Y = 0; Y <= K; Y++) {

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

                if (0 <= S - (X + Y) && S - (X + Y) <= K) {
                    Counter++;
                }
            }
        }
        System.out.println(Counter);
    } main {
        Scanner Input = new Scanner(System.in);
        int K = Input.nextInt();
        int S = Input.nextInt();
        int Counter = 0;
        for (int X = 0; X <= K; X++) {
            for (int Y = 0; Y <= K; Y++) {

                if (0 <= S - (X + Y) && S - (X + Y) <= K) {
                    Counter++;
                }
            }
        }
        System.out.println(Counter);
    } Scanner Input = new Scanner(System.in); Input new Scanner(System.in) int K = Input.nextInt(); K Input.nextInt() Input.nextInt Input int S = Input.nextInt(); S Input.nextInt() Input.nextInt Input int Counter = 0; Counter 0 for (int X = 0; X <= K; X++) {
            for (int Y = 0; Y <= K; Y++) {

                if (0 <= S - (X + Y) && S - (X + Y) <= K) {
                    Counter++;
                }
            }
        } int X = 0; int X = 0; X 0 X <= K X K X++ X++ X {
            for (int Y = 0; Y <= K; Y++) {

                if (0 <= S - (X + Y) && S - (X + Y) <= K) {
                    Counter++;
                }
            }
        } {
            for (int Y = 0; Y <= K; Y++) {

                if (0 <= S - (X + Y) && S - (X + Y) <= K) {
                    Counter++;
                }
            }
        } for (int Y = 0; Y <= K; Y++) {

                if (0 <= S - (X + Y) && S - (X + Y) <= K) {
                    Counter++;
                }
            } int Y = 0; int Y = 0; Y 0 Y <= K Y K Y++ Y++ Y {

                if (0 <= S - (X + Y) && S - (X + Y) <= K) {
                    Counter++;
                }
            } {

                if (0 <= S - (X + Y) && S - (X + Y) <= K) {
                    Counter++;
                }
            } if (0 <= S - (X + Y) && S - (X + Y) <= K) {
                    Counter++;
                } 0 <= S - (X + Y) && S - (X + Y) <= K 0 <= S - (X + Y) 0 S - (X + Y) S (X + Y) X Y S - (X + Y) <= K S - (X + Y) S (X + Y) X Y K {
                    Counter++;
                } Counter++ Counter System.out.println(Counter) System.out.println System.out System System.out Counter String[] args args public class Main {

    public static void main(String[] args) {
        Scanner Input = new Scanner(System.in);
        int K = Input.nextInt();
        int S = Input.nextInt();
        int Counter = 0;
        for (int X = 0; X <= K; X++) {
            for (int Y = 0; Y <= K; Y++) {

                if (0 <= S - (X + Y) && S - (X + Y) <= K) {
                    Counter++;
                }
            }
        }
        System.out.println(Counter);
    }
} public class Main {

    public static void main(String[] args) {
        Scanner Input = new Scanner(System.in);
        int K = Input.nextInt();
        int S = Input.nextInt();
        int Counter = 0;
        for (int X = 0; X <= K; X++) {
            for (int Y = 0; Y <= K; Y++) {

                if (0 <= S - (X + Y) && S - (X + Y) <= K) {
                    Counter++;
                }
            }
        }
        System.out.println(Counter);
    }
} Main

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner Input = new Scanner(System.in);
        int K = Input.nextInt();
        int S = Input.nextInt();
        int Counter = 0;
        for (int X = 0; X <= K; X++) {
            for (int Y = 0; Y <= K; Y++) {

                if (0 <= S - (X + Y) && S - (X + Y) <= K) {
                    Counter++;
                }
            }
        }
        System.out.println(Counter);
    }
}
