import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int total = 0;
        for(int i = 0;i <= K;i++){
            for(int j = 0;j <= K;j++){
                    int last = S - i - j;
                    if(last >= 0 && last <= K) total++;
            }
        }
        System.out.println(total);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int total = 0;
        for(int i = 0;i <= K;i++){
            for(int j = 0;j <= K;j++){
                    int last = S - i - j;
                    if(last >= 0 && last <= K) total++;
            }
        }
        System.out.println(total);
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int total = 0;
        for(int i = 0;i <= K;i++){
            for(int j = 0;j <= K;j++){
                    int last = S - i - j;
                    if(last >= 0 && last <= K) total++;
            }
        }
        System.out.println(total);
    } main {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int total = 0;
        for(int i = 0;i <= K;i++){
            for(int j = 0;j <= K;j++){
                    int last = S - i - j;
                    if(last >= 0 && last <= K) total++;
            }
        }
        System.out.println(total);
    } 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 total = 0; total 0 for(int i = 0;i <= K;i++){
            for(int j = 0;j <= K;j++){
                    int last = S - i - j;
                    if(last >= 0 && last <= K) total++;
            }
        } int i = 0; int i = 0; i 0 i <= K i K i++ i++ i {
            for(int j = 0;j <= K;j++){
                    int last = S - i - j;
                    if(last >= 0 && last <= K) total++;
            }
        } {
            for(int j = 0;j <= K;j++){
                    int last = S - i - j;
                    if(last >= 0 && last <= K) total++;
            }
        } for(int j = 0;j <= K;j++){
                    int last = S - i - j;
                    if(last >= 0 && last <= K) total++;
            } int j = 0; int j = 0; j 0 j <= K j K j++ j++ j {
                    int last = S - i - j;
                    if(last >= 0 && last <= K) total++;
            } {
                    int last = S - i - j;
                    if(last >= 0 && last <= K) total++;
            } int last = S - i - j; last S - i - j S - i - j S i j if(last >= 0 && last <= K) total++; last >= 0 && last <= K last >= 0 last 0 last <= K last K total++ total System.out.println(total) System.out.println System.out System System.out total String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int total = 0;
        for(int i = 0;i <= K;i++){
            for(int j = 0;j <= K;j++){
                    int last = S - i - j;
                    if(last >= 0 && last <= K) total++;
            }
        }
        System.out.println(total);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int total = 0;
        for(int i = 0;i <= K;i++){
            for(int j = 0;j <= K;j++){
                    int last = S - i - j;
                    if(last >= 0 && last <= K) total++;
            }
        }
        System.out.println(total);
    }
} Main
import java.util.*;

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