import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int K = in.nextInt();
            int S = in.nextInt();
            int count = 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)) {
                        continue;
                    }
                    count++;
                }
            }
            System.out.println(count);
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int K = in.nextInt();
            int S = in.nextInt();
            int count = 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)) {
                        continue;
                    }
                    count++;
                }
            }
            System.out.println(count);
        }
    }
} Main public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int K = in.nextInt();
            int S = in.nextInt();
            int count = 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)) {
                        continue;
                    }
                    count++;
                }
            }
            System.out.println(count);
        }
    } main {
        try (Scanner in = new Scanner(System.in)) {
            int K = in.nextInt();
            int S = in.nextInt();
            int count = 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)) {
                        continue;
                    }
                    count++;
                }
            }
            System.out.println(count);
        }
    } try (Scanner in = new Scanner(System.in)) {
            int K = in.nextInt();
            int S = in.nextInt();
            int count = 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)) {
                        continue;
                    }
                    count++;
                }
            }
            System.out.println(count);
        } {
            int K = in.nextInt();
            int S = in.nextInt();
            int count = 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)) {
                        continue;
                    }
                    count++;
                }
            }
            System.out.println(count);
        } Scanner in = new Scanner(System.in) Scanner in = new Scanner(System.in) new Scanner(System.in) int K = in.nextInt(); K in.nextInt() in.nextInt in int S = in.nextInt(); S in.nextInt() in.nextInt in 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 (!(Z >= 0 && Z <= K)) {
                        continue;
                    }
                    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 (!(Z >= 0 && Z <= K)) {
                        continue;
                    }
                    count++;
                }
            } {
                for (int Y = 0; Y <= K; Y++) {
                    int Z = S - (X + Y);
                    if (!(Z >= 0 && Z <= K)) {
                        continue;
                    }
                    count++;
                }
            } for (int Y = 0; Y <= K; Y++) {
                    int Z = S - (X + Y);
                    if (!(Z >= 0 && Z <= K)) {
                        continue;
                    }
                    count++;
                } 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)) {
                        continue;
                    }
                    count++;
                } {
                    int Z = S - (X + Y);
                    if (!(Z >= 0 && Z <= K)) {
                        continue;
                    }
                    count++;
                } int Z = S - (X + Y); Z S - (X + Y) S (X + Y) X Y if (!(Z >= 0 && Z <= K)) {
                        continue;
                    } !(Z >= 0 && Z <= K) (Z >= 0 && Z <= K) Z >= 0 Z 0 Z <= K Z K {
                        continue;
                    } continue; 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[]) {
        try (Scanner in = new Scanner(System.in)) {
            int K = in.nextInt();
            int S = in.nextInt();
            int count = 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)) {
                        continue;
                    }
                    count++;
                }
            }
            System.out.println(count);
        }
    }
} public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int K = in.nextInt();
            int S = in.nextInt();
            int count = 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)) {
                        continue;
                    }
                    count++;
                }
            }
            System.out.println(count);
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int K = in.nextInt();
            int S = in.nextInt();
            int count = 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)) {
                        continue;
                    }
                    count++;
                }
            }
            System.out.println(count);
        }
    }
}
