// "static void main" must be defined in a public class.
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int K = scan.nextInt();
        int S = scan.nextInt();
        int ans = 0;
        for(int i = 0; i <= K; i++){
            for(int j = 0; j <= K; j++){
                if(S-i-j <= K && S-i-j >= 0){
                    ans++;
                }else if(S-i-j <= 0){break;}
            }
        }
        System.out.println(ans);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int K = scan.nextInt();
        int S = scan.nextInt();
        int ans = 0;
        for(int i = 0; i <= K; i++){
            for(int j = 0; j <= K; j++){
                if(S-i-j <= K && S-i-j >= 0){
                    ans++;
                }else if(S-i-j <= 0){break;}
            }
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int K = scan.nextInt();
        int S = scan.nextInt();
        int ans = 0;
        for(int i = 0; i <= K; i++){
            for(int j = 0; j <= K; j++){
                if(S-i-j <= K && S-i-j >= 0){
                    ans++;
                }else if(S-i-j <= 0){break;}
            }
        }
        System.out.println(ans);
    } main {
        Scanner scan = new Scanner(System.in);
        int K = scan.nextInt();
        int S = scan.nextInt();
        int ans = 0;
        for(int i = 0; i <= K; i++){
            for(int j = 0; j <= K; j++){
                if(S-i-j <= K && S-i-j >= 0){
                    ans++;
                }else if(S-i-j <= 0){break;}
            }
        }
        System.out.println(ans);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int K = scan.nextInt(); K scan.nextInt() scan.nextInt scan int S = scan.nextInt(); S scan.nextInt() scan.nextInt scan int ans = 0; ans 0 for(int i = 0; i <= K; i++){
            for(int j = 0; j <= K; j++){
                if(S-i-j <= K && S-i-j >= 0){
                    ans++;
                }else if(S-i-j <= 0){break;}
            }
        } int i = 0; int i = 0; i 0 i <= K i K i++ i++ i {
            for(int j = 0; j <= K; j++){
                if(S-i-j <= K && S-i-j >= 0){
                    ans++;
                }else if(S-i-j <= 0){break;}
            }
        } {
            for(int j = 0; j <= K; j++){
                if(S-i-j <= K && S-i-j >= 0){
                    ans++;
                }else if(S-i-j <= 0){break;}
            }
        } for(int j = 0; j <= K; j++){
                if(S-i-j <= K && S-i-j >= 0){
                    ans++;
                }else if(S-i-j <= 0){break;}
            } int j = 0; int j = 0; j 0 j <= K j K j++ j++ j {
                if(S-i-j <= K && S-i-j >= 0){
                    ans++;
                }else if(S-i-j <= 0){break;}
            } {
                if(S-i-j <= K && S-i-j >= 0){
                    ans++;
                }else if(S-i-j <= 0){break;}
            } if(S-i-j <= K && S-i-j >= 0){
                    ans++;
                }else if(S-i-j <= 0){break;} S-i-j <= K && S-i-j >= 0 S-i-j <= K S-i-j S-i-j S i j K S-i-j >= 0 S-i-j S-i-j S i j 0 {
                    ans++;
                } ans++ ans if(S-i-j <= 0){break;} S-i-j <= 0 S-i-j S-i-j S i j 0 {break;} break; System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int K = scan.nextInt();
        int S = scan.nextInt();
        int ans = 0;
        for(int i = 0; i <= K; i++){
            for(int j = 0; j <= K; j++){
                if(S-i-j <= K && S-i-j >= 0){
                    ans++;
                }else if(S-i-j <= 0){break;}
            }
        }
        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int K = scan.nextInt();
        int S = scan.nextInt();
        int ans = 0;
        for(int i = 0; i <= K; i++){
            for(int j = 0; j <= K; j++){
                if(S-i-j <= K && S-i-j >= 0){
                    ans++;
                }else if(S-i-j <= 0){break;}
            }
        }
        System.out.println(ans);
    }
} Main
// "static void main" must be defined in a public class.
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int K = scan.nextInt();
        int S = scan.nextInt();
        int ans = 0;
        for(int i = 0; i <= K; i++){
            for(int j = 0; j <= K; j++){
                if(S-i-j <= K && S-i-j >= 0){
                    ans++;
                }else if(S-i-j <= 0){break;}
            }
        }
        System.out.println(ans);
    }
}