import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int K = sc.nextInt();
        int S = sc.nextInt();
        int[] sMinusZ = new int[K + 1];
        for (int i=0; i<=K; i++) {
            sMinusZ[i] = S - i;
        }
        Arrays.sort(sMinusZ);

        int sum = 0;
        for (int i=0; i<=K; i++) {
            for (int j=0; j<=K; j++) {
                if (Arrays.binarySearch(sMinusZ, i+j) >= 0) {
                    sum++;
                }
            }
        }

        System.out.println(sum);
    }
}
 import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int K = sc.nextInt();
        int S = sc.nextInt();
        int[] sMinusZ = new int[K + 1];
        for (int i=0; i<=K; i++) {
            sMinusZ[i] = S - i;
        }
        Arrays.sort(sMinusZ);

        int sum = 0;
        for (int i=0; i<=K; i++) {
            for (int j=0; j<=K; j++) {
                if (Arrays.binarySearch(sMinusZ, i+j) >= 0) {
                    sum++;
                }
            }
        }

        System.out.println(sum);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int K = sc.nextInt();
        int S = sc.nextInt();
        int[] sMinusZ = new int[K + 1];
        for (int i=0; i<=K; i++) {
            sMinusZ[i] = S - i;
        }
        Arrays.sort(sMinusZ);

        int sum = 0;
        for (int i=0; i<=K; i++) {
            for (int j=0; j<=K; j++) {
                if (Arrays.binarySearch(sMinusZ, i+j) >= 0) {
                    sum++;
                }
            }
        }

        System.out.println(sum);
    } main {
        Scanner sc = new Scanner(System.in);

        int K = sc.nextInt();
        int S = sc.nextInt();
        int[] sMinusZ = new int[K + 1];
        for (int i=0; i<=K; i++) {
            sMinusZ[i] = S - i;
        }
        Arrays.sort(sMinusZ);

        int sum = 0;
        for (int i=0; i<=K; i++) {
            for (int j=0; j<=K; j++) {
                if (Arrays.binarySearch(sMinusZ, i+j) >= 0) {
                    sum++;
                }
            }
        }

        System.out.println(sum);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc int S = sc.nextInt(); S sc.nextInt() sc.nextInt sc int[] sMinusZ = new int[K + 1]; sMinusZ new int[K + 1] K + 1 K 1 for (int i=0; i<=K; i++) {
            sMinusZ[i] = S - i;
        } int i=0; int i=0; i 0 i<=K i K i++ i++ i {
            sMinusZ[i] = S - i;
        } {
            sMinusZ[i] = S - i;
        } sMinusZ[i] = S - i sMinusZ[i] sMinusZ i S - i S i Arrays.sort(sMinusZ) Arrays.sort Arrays sMinusZ int sum = 0; sum 0 for (int i=0; i<=K; i++) {
            for (int j=0; j<=K; j++) {
                if (Arrays.binarySearch(sMinusZ, i+j) >= 0) {
                    sum++;
                }
            }
        } int i=0; int i=0; i 0 i<=K i K i++ i++ i {
            for (int j=0; j<=K; j++) {
                if (Arrays.binarySearch(sMinusZ, i+j) >= 0) {
                    sum++;
                }
            }
        } {
            for (int j=0; j<=K; j++) {
                if (Arrays.binarySearch(sMinusZ, i+j) >= 0) {
                    sum++;
                }
            }
        } for (int j=0; j<=K; j++) {
                if (Arrays.binarySearch(sMinusZ, i+j) >= 0) {
                    sum++;
                }
            } int j=0; int j=0; j 0 j<=K j K j++ j++ j {
                if (Arrays.binarySearch(sMinusZ, i+j) >= 0) {
                    sum++;
                }
            } {
                if (Arrays.binarySearch(sMinusZ, i+j) >= 0) {
                    sum++;
                }
            } if (Arrays.binarySearch(sMinusZ, i+j) >= 0) {
                    sum++;
                } Arrays.binarySearch(sMinusZ, i+j) >= 0 Arrays.binarySearch(sMinusZ, i+j) Arrays.binarySearch Arrays sMinusZ i+j i j 0 {
                    sum++;
                } sum++ sum System.out.println(sum) System.out.println System.out System System.out sum String[] args args
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int K = sc.nextInt();
        int S = sc.nextInt();
        int[] sMinusZ = new int[K + 1];
        for (int i=0; i<=K; i++) {
            sMinusZ[i] = S - i;
        }
        Arrays.sort(sMinusZ);

        int sum = 0;
        for (int i=0; i<=K; i++) {
            for (int j=0; j<=K; j++) {
                if (Arrays.binarySearch(sMinusZ, i+j) >= 0) {
                    sum++;
                }
            }
        }

        System.out.println(sum);
    }
}

