import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());
        int ans = 0;
        for (int i = 0; i <= k; i++) {
            for(int j = 0; j <= k; j++) {
                int l = s - i - j;
                if (l >= 0 && l <= 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 = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());
        int ans = 0;
        for (int i = 0; i <= k; i++) {
            for(int j = 0; j <= k; j++) {
                int l = s - i - j;
                if (l >= 0 && l <= k) {
                    ans++;
                }
            }
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());
        int ans = 0;
        for (int i = 0; i <= k; i++) {
            for(int j = 0; j <= k; j++) {
                int l = s - i - j;
                if (l >= 0 && l <= k) {
                    ans++;
                }
            }
        }
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());
        int ans = 0;
        for (int i = 0; i <= k; i++) {
            for(int j = 0; j <= k; j++) {
                int l = s - i - j;
                if (l >= 0 && l <= k) {
                    ans++;
                }
            }
        }
        System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int k = Integer.parseInt(sc.next()); k Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int s = Integer.parseInt(sc.next()); s Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int ans = 0; ans 0 for (int i = 0; i <= k; i++) {
            for(int j = 0; j <= k; j++) {
                int l = s - i - j;
                if (l >= 0 && l <= k) {
                    ans++;
                }
            }
        } int i = 0; int i = 0; i 0 i <= k i k i++ i++ i {
            for(int j = 0; j <= k; j++) {
                int l = s - i - j;
                if (l >= 0 && l <= k) {
                    ans++;
                }
            }
        } {
            for(int j = 0; j <= k; j++) {
                int l = s - i - j;
                if (l >= 0 && l <= k) {
                    ans++;
                }
            }
        } for(int j = 0; j <= k; j++) {
                int l = s - i - j;
                if (l >= 0 && l <= k) {
                    ans++;
                }
            } int j = 0; int j = 0; j 0 j <= k j k j++ j++ j {
                int l = s - i - j;
                if (l >= 0 && l <= k) {
                    ans++;
                }
            } {
                int l = s - i - j;
                if (l >= 0 && l <= k) {
                    ans++;
                }
            } int l = s - i - j; l s - i - j s - i - j s i j if (l >= 0 && l <= k) {
                    ans++;
                } l >= 0 && l <= k l >= 0 l 0 l <= k l 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 = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());
        int ans = 0;
        for (int i = 0; i <= k; i++) {
            for(int j = 0; j <= k; j++) {
                int l = s - i - j;
                if (l >= 0 && l <= k) {
                    ans++;
                }
            }
        }
        System.out.println(ans);
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());
        int ans = 0;
        for (int i = 0; i <= k; i++) {
            for(int j = 0; j <= k; j++) {
                int l = s - i - j;
                if (l >= 0 && l <= 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 = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());
        int ans = 0;
        for (int i = 0; i <= k; i++) {
            for(int j = 0; j <= k; j++) {
                int l = s - i - j;
                if (l >= 0 && l <= k) {
                    ans++;
                }
            }
        }
        System.out.println(ans);
    }
}
