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();

        int result = 0;
        for (int i = 0; i < s + 1; i++) {
            int x = i;
            for (int j = 0; j < s + 1 - i; j++) {
                int y = j;
                int z = s - x - y;
                if (x > k || y > k || z > k) {
                    continue;
                }
                result++;
            }
        }
        System.out.println(result);
    }

} 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();

        int result = 0;
        for (int i = 0; i < s + 1; i++) {
            int x = i;
            for (int j = 0; j < s + 1 - i; j++) {
                int y = j;
                int z = s - x - y;
                if (x > k || y > k || z > k) {
                    continue;
                }
                result++;
            }
        }
        System.out.println(result);
    }

} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();

        int result = 0;
        for (int i = 0; i < s + 1; i++) {
            int x = i;
            for (int j = 0; j < s + 1 - i; j++) {
                int y = j;
                int z = s - x - y;
                if (x > k || y > k || z > k) {
                    continue;
                }
                result++;
            }
        }
        System.out.println(result);
    } main {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();

        int result = 0;
        for (int i = 0; i < s + 1; i++) {
            int x = i;
            for (int j = 0; j < s + 1 - i; j++) {
                int y = j;
                int z = s - x - y;
                if (x > k || y > k || z > k) {
                    continue;
                }
                result++;
            }
        }
        System.out.println(result);
    } 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 result = 0; result 0 for (int i = 0; i < s + 1; i++) {
            int x = i;
            for (int j = 0; j < s + 1 - i; j++) {
                int y = j;
                int z = s - x - y;
                if (x > k || y > k || z > k) {
                    continue;
                }
                result++;
            }
        } int i = 0; int i = 0; i 0 i < s + 1 i s + 1 s 1 i++ i++ i {
            int x = i;
            for (int j = 0; j < s + 1 - i; j++) {
                int y = j;
                int z = s - x - y;
                if (x > k || y > k || z > k) {
                    continue;
                }
                result++;
            }
        } {
            int x = i;
            for (int j = 0; j < s + 1 - i; j++) {
                int y = j;
                int z = s - x - y;
                if (x > k || y > k || z > k) {
                    continue;
                }
                result++;
            }
        } int x = i; x i for (int j = 0; j < s + 1 - i; j++) {
                int y = j;
                int z = s - x - y;
                if (x > k || y > k || z > k) {
                    continue;
                }
                result++;
            } int j = 0; int j = 0; j 0 j < s + 1 - i j s + 1 - i s + 1 s 1 i j++ j++ j {
                int y = j;
                int z = s - x - y;
                if (x > k || y > k || z > k) {
                    continue;
                }
                result++;
            } {
                int y = j;
                int z = s - x - y;
                if (x > k || y > k || z > k) {
                    continue;
                }
                result++;
            } int y = j; y j int z = s - x - y; z s - x - y s - x - y s x y if (x > k || y > k || z > k) {
                    continue;
                } x > k || y > k || z > k x > k || y > k || z > k x > k x k y > k y k z > k z k {
                    continue;
                } continue; result++ result System.out.println(result) System.out.println System.out System System.out result 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 result = 0;
        for (int i = 0; i < s + 1; i++) {
            int x = i;
            for (int j = 0; j < s + 1 - i; j++) {
                int y = j;
                int z = s - x - y;
                if (x > k || y > k || z > k) {
                    continue;
                }
                result++;
            }
        }
        System.out.println(result);
    }

} public class Main {

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

        int result = 0;
        for (int i = 0; i < s + 1; i++) {
            int x = i;
            for (int j = 0; j < s + 1 - i; j++) {
                int y = j;
                int z = s - x - y;
                if (x > k || y > k || z > k) {
                    continue;
                }
                result++;
            }
        }
        System.out.println(result);
    }

} 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();

        int result = 0;
        for (int i = 0; i < s + 1; i++) {
            int x = i;
            for (int j = 0; j < s + 1 - i; j++) {
                int y = j;
                int z = s - x - y;
                if (x > k || y > k || z > k) {
                    continue;
                }
                result++;
            }
        }
        System.out.println(result);
    }

}
