import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int K = scanner.nextInt();
        int S = scanner.nextInt();
        scanner.close();
        int combination = 0;
        int k;

        for(int i=0;i<=K;i++) {
            for(int j=0;j<=K;j++) {
                k = S-i-j;
                if(i+j+k==S && i>=0 && j>=0 && k>=0 && k <= K) {
                    combination++;
                }
            }
        }
        System.out.println(combination);
    }
} import java.util.Scanner; Scanner java.util class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int K = scanner.nextInt();
        int S = scanner.nextInt();
        scanner.close();
        int combination = 0;
        int k;

        for(int i=0;i<=K;i++) {
            for(int j=0;j<=K;j++) {
                k = S-i-j;
                if(i+j+k==S && i>=0 && j>=0 && k>=0 && k <= K) {
                    combination++;
                }
            }
        }
        System.out.println(combination);
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int K = scanner.nextInt();
        int S = scanner.nextInt();
        scanner.close();
        int combination = 0;
        int k;

        for(int i=0;i<=K;i++) {
            for(int j=0;j<=K;j++) {
                k = S-i-j;
                if(i+j+k==S && i>=0 && j>=0 && k>=0 && k <= K) {
                    combination++;
                }
            }
        }
        System.out.println(combination);
    } main {
        Scanner scanner = new Scanner(System.in);
        int K = scanner.nextInt();
        int S = scanner.nextInt();
        scanner.close();
        int combination = 0;
        int k;

        for(int i=0;i<=K;i++) {
            for(int j=0;j<=K;j++) {
                k = S-i-j;
                if(i+j+k==S && i>=0 && j>=0 && k>=0 && k <= K) {
                    combination++;
                }
            }
        }
        System.out.println(combination);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int K = scanner.nextInt(); K scanner.nextInt() scanner.nextInt scanner int S = scanner.nextInt(); S scanner.nextInt() scanner.nextInt scanner scanner.close() scanner.close scanner int combination = 0; combination 0 int k; k for(int i=0;i<=K;i++) {
            for(int j=0;j<=K;j++) {
                k = S-i-j;
                if(i+j+k==S && i>=0 && j>=0 && k>=0 && k <= K) {
                    combination++;
                }
            }
        } int i=0; int i=0; i 0 i<=K i K i++ i++ i {
            for(int j=0;j<=K;j++) {
                k = S-i-j;
                if(i+j+k==S && i>=0 && j>=0 && k>=0 && k <= K) {
                    combination++;
                }
            }
        } {
            for(int j=0;j<=K;j++) {
                k = S-i-j;
                if(i+j+k==S && i>=0 && j>=0 && k>=0 && k <= K) {
                    combination++;
                }
            }
        } for(int j=0;j<=K;j++) {
                k = S-i-j;
                if(i+j+k==S && i>=0 && j>=0 && k>=0 && k <= K) {
                    combination++;
                }
            } int j=0; int j=0; j 0 j<=K j K j++ j++ j {
                k = S-i-j;
                if(i+j+k==S && i>=0 && j>=0 && k>=0 && k <= K) {
                    combination++;
                }
            } {
                k = S-i-j;
                if(i+j+k==S && i>=0 && j>=0 && k>=0 && k <= K) {
                    combination++;
                }
            } k = S-i-j k S-i-j S-i-j S i j if(i+j+k==S && i>=0 && j>=0 && k>=0 && k <= K) {
                    combination++;
                } i+j+k==S && i>=0 && j>=0 && k>=0 && k <= K k>=0 j>=0 i+j+k==S && i>=0 && j>=0 && k>=0 && k <= K i+j+k==S i+j+k i+j+k i j k S i>=0 i 0 j>=0 j 0 k>=0 k 0 k <= K k K {
                    combination++;
                } combination++ combination System.out.println(combination) System.out.println System.out System System.out combination String[] args args
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int K = scanner.nextInt();
        int S = scanner.nextInt();
        scanner.close();
        int combination = 0;
        int k;

        for(int i=0;i<=K;i++) {
            for(int j=0;j<=K;j++) {
                k = S-i-j;
                if(i+j+k==S && i>=0 && j>=0 && k>=0 && k <= K) {
                    combination++;
                }
            }
        }
        System.out.println(combination);
    }
}