import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int K = scan.nextInt();
        int S = scan.nextInt();
        long answer = 0;
        for (int x = 0; x <= K; x++) {
            int limit_y = Math.min(K, S - x);
            for (int y = 0; y <= limit_y; y++) {
                if (S - x - y <= K) {
                    answer += 1;
                }
            }
        }
        System.out.println(answer);
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int K = scan.nextInt();
        int S = scan.nextInt();
        long answer = 0;
        for (int x = 0; x <= K; x++) {
            int limit_y = Math.min(K, S - x);
            for (int y = 0; y <= limit_y; y++) {
                if (S - x - y <= K) {
                    answer += 1;
                }
            }
        }
        System.out.println(answer);
    }
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int K = scan.nextInt();
        int S = scan.nextInt();
        long answer = 0;
        for (int x = 0; x <= K; x++) {
            int limit_y = Math.min(K, S - x);
            for (int y = 0; y <= limit_y; y++) {
                if (S - x - y <= K) {
                    answer += 1;
                }
            }
        }
        System.out.println(answer);
    } main {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int K = scan.nextInt();
        int S = scan.nextInt();
        long answer = 0;
        for (int x = 0; x <= K; x++) {
            int limit_y = Math.min(K, S - x);
            for (int y = 0; y <= limit_y; y++) {
                if (S - x - y <= K) {
                    answer += 1;
                }
            }
        }
        System.out.println(answer);
    } Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in))); scan new Scanner(new BufferedReader(new InputStreamReader(System.in))) int K = scan.nextInt(); K scan.nextInt() scan.nextInt scan int S = scan.nextInt(); S scan.nextInt() scan.nextInt scan long answer = 0; answer 0 for (int x = 0; x <= K; x++) {
            int limit_y = Math.min(K, S - x);
            for (int y = 0; y <= limit_y; y++) {
                if (S - x - y <= K) {
                    answer += 1;
                }
            }
        } int x = 0; int x = 0; x 0 x <= K x K x++ x++ x {
            int limit_y = Math.min(K, S - x);
            for (int y = 0; y <= limit_y; y++) {
                if (S - x - y <= K) {
                    answer += 1;
                }
            }
        } {
            int limit_y = Math.min(K, S - x);
            for (int y = 0; y <= limit_y; y++) {
                if (S - x - y <= K) {
                    answer += 1;
                }
            }
        } int limit_y = Math.min(K, S - x); limit_y Math.min(K, S - x) Math.min Math K S - x S x for (int y = 0; y <= limit_y; y++) {
                if (S - x - y <= K) {
                    answer += 1;
                }
            } int y = 0; int y = 0; y 0 y <= limit_y y limit_y y++ y++ y {
                if (S - x - y <= K) {
                    answer += 1;
                }
            } {
                if (S - x - y <= K) {
                    answer += 1;
                }
            } if (S - x - y <= K) {
                    answer += 1;
                } S - x - y <= K S - x - y S - x - y S x y K {
                    answer += 1;
                } answer += 1 answer 1 System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int K = scan.nextInt();
        int S = scan.nextInt();
        long answer = 0;
        for (int x = 0; x <= K; x++) {
            int limit_y = Math.min(K, S - x);
            for (int y = 0; y <= limit_y; y++) {
                if (S - x - y <= K) {
                    answer += 1;
                }
            }
        }
        System.out.println(answer);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int K = scan.nextInt();
        int S = scan.nextInt();
        long answer = 0;
        for (int x = 0; x <= K; x++) {
            int limit_y = Math.min(K, S - x);
            for (int y = 0; y <= limit_y; y++) {
                if (S - x - y <= K) {
                    answer += 1;
                }
            }
        }
        System.out.println(answer);
    }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int K = scan.nextInt();
        int S = scan.nextInt();
        long answer = 0;
        for (int x = 0; x <= K; x++) {
            int limit_y = Math.min(K, S - x);
            for (int y = 0; y <= limit_y; y++) {
                if (S - x - y <= K) {
                    answer += 1;
                }
            }
        }
        System.out.println(answer);
    }
}
