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 a;
        int b;
        int cnt = 0;
        for (a = 0; a <= K; a++) {
            int qw = K;
            if (S - a < qw) {
                qw = S-a;
                }for (b = 0; b <= qw; b++) {
                if (S - a - b <= K) cnt++;
                
            }
        }
        System.out.println(cnt);
    }
} 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 a;
        int b;
        int cnt = 0;
        for (a = 0; a <= K; a++) {
            int qw = K;
            if (S - a < qw) {
                qw = S-a;
                }for (b = 0; b <= qw; b++) {
                if (S - a - b <= K) cnt++;
                
            }
        }
        System.out.println(cnt);
    }
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int K = scan.nextInt();
        int S = scan.nextInt();
        int a;
        int b;
        int cnt = 0;
        for (a = 0; a <= K; a++) {
            int qw = K;
            if (S - a < qw) {
                qw = S-a;
                }for (b = 0; b <= qw; b++) {
                if (S - a - b <= K) cnt++;
                
            }
        }
        System.out.println(cnt);
    } main {
        Scanner scan = new Scanner(System.in);
        int K = scan.nextInt();
        int S = scan.nextInt();
        int a;
        int b;
        int cnt = 0;
        for (a = 0; a <= K; a++) {
            int qw = K;
            if (S - a < qw) {
                qw = S-a;
                }for (b = 0; b <= qw; b++) {
                if (S - a - b <= K) cnt++;
                
            }
        }
        System.out.println(cnt);
    } 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 a; a int b; b int cnt = 0; cnt 0 for (a = 0; a <= K; a++) {
            int qw = K;
            if (S - a < qw) {
                qw = S-a;
                }for (b = 0; b <= qw; b++) {
                if (S - a - b <= K) cnt++;
                
            }
        } a = 0; a = 0 a 0 a <= K a K a++ a++ a {
            int qw = K;
            if (S - a < qw) {
                qw = S-a;
                }for (b = 0; b <= qw; b++) {
                if (S - a - b <= K) cnt++;
                
            }
        } {
            int qw = K;
            if (S - a < qw) {
                qw = S-a;
                }for (b = 0; b <= qw; b++) {
                if (S - a - b <= K) cnt++;
                
            }
        } int qw = K; qw K if (S - a < qw) {
                qw = S-a;
                } S - a < qw S - a S a qw {
                qw = S-a;
                } qw = S-a qw S-a S a for (b = 0; b <= qw; b++) {
                if (S - a - b <= K) cnt++;
                
            } b = 0; b = 0 b 0 b <= qw b qw b++ b++ b {
                if (S - a - b <= K) cnt++;
                
            } {
                if (S - a - b <= K) cnt++;
                
            } if (S - a - b <= K) cnt++; S - a - b <= K S - a - b S - a - b S a b K cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt 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 a;
        int b;
        int cnt = 0;
        for (a = 0; a <= K; a++) {
            int qw = K;
            if (S - a < qw) {
                qw = S-a;
                }for (b = 0; b <= qw; b++) {
                if (S - a - b <= K) cnt++;
                
            }
        }
        System.out.println(cnt);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int K = scan.nextInt();
        int S = scan.nextInt();
        int a;
        int b;
        int cnt = 0;
        for (a = 0; a <= K; a++) {
            int qw = K;
            if (S - a < qw) {
                qw = S-a;
                }for (b = 0; b <= qw; b++) {
                if (S - a - b <= K) cnt++;
                
            }
        }
        System.out.println(cnt);
    }
} Main
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 a;
        int b;
        int cnt = 0;
        for (a = 0; a <= K; a++) {
            int qw = K;
            if (S - a < qw) {
                qw = S-a;
                }for (b = 0; b <= qw; b++) {
                if (S - a - b <= K) cnt++;
                
            }
        }
        System.out.println(cnt);
    }
}