import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        sc.close();

        int ans = 0;
        for (int i = 0; i <= K; ++i) {
            for (int j = 0; j <= K; ++j) {
                if (S - i - j >= 0 && S - i - j <= K) {
                    ans++;
                } 
            }
        }

        System.out.println(ans);
	}
} import java.util.Scanner; Scanner 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();
        sc.close();

        int ans = 0;
        for (int i = 0; i <= K; ++i) {
            for (int j = 0; j <= K; ++j) {
                if (S - i - j >= 0 && S - i - j <= K) {
                    ans++;
                } 
            }
        }

        System.out.println(ans);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        sc.close();

        int ans = 0;
        for (int i = 0; i <= K; ++i) {
            for (int j = 0; j <= K; ++j) {
                if (S - i - j >= 0 && S - i - j <= K) {
                    ans++;
                } 
            }
        }

        System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        sc.close();

        int ans = 0;
        for (int i = 0; i <= K; ++i) {
            for (int j = 0; j <= K; ++j) {
                if (S - i - j >= 0 && S - i - j <= K) {
                    ans++;
                } 
            }
        }

        System.out.println(ans);
	} 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 sc.close() sc.close sc int ans = 0; ans 0 for (int i = 0; i <= K; ++i) {
            for (int j = 0; j <= K; ++j) {
                if (S - i - j >= 0 && S - i - j <= K) {
                    ans++;
                } 
            }
        } 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 >= 0 && S - i - j <= K) {
                    ans++;
                } 
            }
        } {
            for (int j = 0; j <= K; ++j) {
                if (S - i - j >= 0 && S - i - j <= K) {
                    ans++;
                } 
            }
        } for (int j = 0; j <= K; ++j) {
                if (S - i - j >= 0 && S - i - j <= K) {
                    ans++;
                } 
            } int j = 0; int j = 0; j 0 j <= K j K ++j ++j j {
                if (S - i - j >= 0 && S - i - j <= K) {
                    ans++;
                } 
            } {
                if (S - i - j >= 0 && S - i - j <= K) {
                    ans++;
                } 
            } if (S - i - j >= 0 && S - i - j <= K) {
                    ans++;
                } S - i - j >= 0 && S - i - j <= K S - i - j >= 0 S - i - j S - i - j S i j 0 S - i - j <= K S - i - j S - i - j S i j K {
                    ans++;
                } ans++ ans 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 sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        sc.close();

        int ans = 0;
        for (int i = 0; i <= K; ++i) {
            for (int j = 0; j <= K; ++j) {
                if (S - i - j >= 0 && S - i - j <= K) {
                    ans++;
                } 
            }
        }

        System.out.println(ans);
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        sc.close();

        int ans = 0;
        for (int i = 0; i <= K; ++i) {
            for (int j = 0; j <= K; ++j) {
                if (S - i - j >= 0 && S - i - j <= K) {
                    ans++;
                } 
            }
        }

        System.out.println(ans);
	}
} Main
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        sc.close();

        int ans = 0;
        for (int i = 0; i <= K; ++i) {
            for (int j = 0; j <= K; ++j) {
                if (S - i - j >= 0 && S - i - j <= K) {
                    ans++;
                } 
            }
        }

        System.out.println(ans);
	}
}
