import java.util.*;

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

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int count = 0;
        for(int i=0;i<=K;i++){
            for(int j=0;j<=i;j++){
                for(int k=0;k<=j;k++){
                    int a = i+j+k;
                    if(a == S){
                        if(i == j && j== k){
                            count ++;
                        }else if(i != j && j != k && k != i){
                            count += 6;
                        }else{
                            count += 3;
                        }
                    }
                }
            }
        }
        System.out.println(count);
    }
}   