import java.util.Scanner;

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

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

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

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

}