import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int K = scan.nextInt(), S = scan.nextInt();
        int x, y, cnt = 0;

        for (x=0; x <= K; x++) {
            int ylim = K;
            if (S-x < ylim) ylim = S-x;

            for (y=0; y <= ylim; y++) {
                if (S - x - y <= K) cnt++;
            }
        }

        System.out.println(cnt);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int K = scan.nextInt(), S = scan.nextInt();
        int x, y, cnt = 0;

        for (x=0; x <= K; x++) {
            int ylim = K;
            if (S-x < ylim) ylim = S-x;

            for (y=0; y <= ylim; y++) {
                if (S - x - y <= K) cnt++;
            }
        }

        System.out.println(cnt);
    }
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int K = scan.nextInt(), S = scan.nextInt();
        int x, y, cnt = 0;

        for (x=0; x <= K; x++) {
            int ylim = K;
            if (S-x < ylim) ylim = S-x;

            for (y=0; y <= ylim; y++) {
                if (S - x - y <= K) cnt++;
            }
        }

        System.out.println(cnt);
    } main {
        Scanner scan = new Scanner(System.in);
        int K = scan.nextInt(), S = scan.nextInt();
        int x, y, cnt = 0;

        for (x=0; x <= K; x++) {
            int ylim = K;
            if (S-x < ylim) ylim = S-x;

            for (y=0; y <= ylim; y++) {
                if (S - x - y <= K) cnt++;
            }
        }

        System.out.println(cnt);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int K = scan.nextInt() K scan.nextInt() scan.nextInt scan S = scan.nextInt(); S scan.nextInt() scan.nextInt scan int x x y y cnt = 0; cnt 0 for (x=0; x <= K; x++) {
            int ylim = K;
            if (S-x < ylim) ylim = S-x;

            for (y=0; y <= ylim; y++) {
                if (S - x - y <= K) cnt++;
            }
        } x=0; x=0 x 0 x <= K x K x++ x++ x {
            int ylim = K;
            if (S-x < ylim) ylim = S-x;

            for (y=0; y <= ylim; y++) {
                if (S - x - y <= K) cnt++;
            }
        } {
            int ylim = K;
            if (S-x < ylim) ylim = S-x;

            for (y=0; y <= ylim; y++) {
                if (S - x - y <= K) cnt++;
            }
        } int ylim = K; ylim K if (S-x < ylim) ylim = S-x; S-x < ylim S-x S x ylim ylim = S-x ylim S-x S x for (y=0; y <= ylim; y++) {
                if (S - x - y <= K) cnt++;
            } y=0; y=0 y 0 y <= ylim y ylim y++ y++ y {
                if (S - x - y <= K) cnt++;
            } {
                if (S - x - y <= K) cnt++;
            } if (S - x - y <= K) cnt++; S - x - y <= K S - x - y S - x - y S x y K cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int K = scan.nextInt(), S = scan.nextInt();
        int x, y, cnt = 0;

        for (x=0; x <= K; x++) {
            int ylim = K;
            if (S-x < ylim) ylim = S-x;

            for (y=0; y <= ylim; y++) {
                if (S - x - y <= K) cnt++;
            }
        }

        System.out.println(cnt);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int K = scan.nextInt(), S = scan.nextInt();
        int x, y, cnt = 0;

        for (x=0; x <= K; x++) {
            int ylim = K;
            if (S-x < ylim) ylim = S-x;

            for (y=0; y <= ylim; y++) {
                if (S - x - y <= K) cnt++;
            }
        }

        System.out.println(cnt);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int K = scan.nextInt(), S = scan.nextInt();
        int x, y, cnt = 0;

        for (x=0; x <= K; x++) {
            int ylim = K;
            if (S-x < ylim) ylim = S-x;

            for (y=0; y <= ylim; y++) {
                if (S - x - y <= K) cnt++;
            }
        }

        System.out.println(cnt);
    }
}
