import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int K = cin.nextInt();
        int S = cin.nextInt();
        int c = 0;
        for (int x = 0; x <= K; x++) {
            for (int y = 0; y <= K; y++) {
                int z = S - x - y;
                if (z >= 0 && z <= K) {
                    c++;
                }
            }
        }
        System.out.println(c);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int K = cin.nextInt();
        int S = cin.nextInt();
        int c = 0;
        for (int x = 0; x <= K; x++) {
            for (int y = 0; y <= K; y++) {
                int z = S - x - y;
                if (z >= 0 && z <= K) {
                    c++;
                }
            }
        }
        System.out.println(c);
    }
} Main public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int K = cin.nextInt();
        int S = cin.nextInt();
        int c = 0;
        for (int x = 0; x <= K; x++) {
            for (int y = 0; y <= K; y++) {
                int z = S - x - y;
                if (z >= 0 && z <= K) {
                    c++;
                }
            }
        }
        System.out.println(c);
    } main {
        Scanner cin = new Scanner(System.in);
        int K = cin.nextInt();
        int S = cin.nextInt();
        int c = 0;
        for (int x = 0; x <= K; x++) {
            for (int y = 0; y <= K; y++) {
                int z = S - x - y;
                if (z >= 0 && z <= K) {
                    c++;
                }
            }
        }
        System.out.println(c);
    } Scanner cin = new Scanner(System.in); cin new Scanner(System.in) int K = cin.nextInt(); K cin.nextInt() cin.nextInt cin int S = cin.nextInt(); S cin.nextInt() cin.nextInt cin int c = 0; c 0 for (int x = 0; x <= K; x++) {
            for (int y = 0; y <= K; y++) {
                int z = S - x - y;
                if (z >= 0 && z <= K) {
                    c++;
                }
            }
        } 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 (z >= 0 && z <= K) {
                    c++;
                }
            }
        } {
            for (int y = 0; y <= K; y++) {
                int z = S - x - y;
                if (z >= 0 && z <= K) {
                    c++;
                }
            }
        } for (int y = 0; y <= K; y++) {
                int z = S - x - y;
                if (z >= 0 && z <= K) {
                    c++;
                }
            } int y = 0; int y = 0; y 0 y <= K y K y++ y++ y {
                int z = S - x - y;
                if (z >= 0 && z <= K) {
                    c++;
                }
            } {
                int z = S - x - y;
                if (z >= 0 && z <= K) {
                    c++;
                }
            } int z = S - x - y; z S - x - y S - x - y S x y if (z >= 0 && z <= K) {
                    c++;
                } z >= 0 && z <= K z >= 0 z 0 z <= K z K {
                    c++;
                } c++ c System.out.println(c) System.out.println System.out System System.out c String[] args args public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int K = cin.nextInt();
        int S = cin.nextInt();
        int c = 0;
        for (int x = 0; x <= K; x++) {
            for (int y = 0; y <= K; y++) {
                int z = S - x - y;
                if (z >= 0 && z <= K) {
                    c++;
                }
            }
        }
        System.out.println(c);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int K = cin.nextInt();
        int S = cin.nextInt();
        int c = 0;
        for (int x = 0; x <= K; x++) {
            for (int y = 0; y <= K; y++) {
                int z = S - x - y;
                if (z >= 0 && z <= K) {
                    c++;
                }
            }
        }
        System.out.println(c);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int K = cin.nextInt();
        int S = cin.nextInt();
        int c = 0;
        for (int x = 0; x <= K; x++) {
            for (int y = 0; y <= K; y++) {
                int z = S - x - y;
                if (z >= 0 && z <= K) {
                    c++;
                }
            }
        }
        System.out.println(c);
    }
}