import java.util.Scanner;

public class Main {
    private static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int k = scanner.nextInt();
        int s = scanner.nextInt();
        int answer = 0;
        for (int x = 0; x <= k; x++)
            answer += (s - x + 1) - Math.min(s - x + 1, Math.max(0, ((s - x - k) * 2)));
        System.out.println(answer);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    private static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int k = scanner.nextInt();
        int s = scanner.nextInt();
        int answer = 0;
        for (int x = 0; x <= k; x++)
            answer += (s - x + 1) - Math.min(s - x + 1, Math.max(0, ((s - x - k) * 2)));
        System.out.println(answer);
    }
} Main private static Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) public static void main(String[] args) {
        int k = scanner.nextInt();
        int s = scanner.nextInt();
        int answer = 0;
        for (int x = 0; x <= k; x++)
            answer += (s - x + 1) - Math.min(s - x + 1, Math.max(0, ((s - x - k) * 2)));
        System.out.println(answer);
    } main {
        int k = scanner.nextInt();
        int s = scanner.nextInt();
        int answer = 0;
        for (int x = 0; x <= k; x++)
            answer += (s - x + 1) - Math.min(s - x + 1, Math.max(0, ((s - x - k) * 2)));
        System.out.println(answer);
    } int k = scanner.nextInt(); k scanner.nextInt() scanner.nextInt scanner int s = scanner.nextInt(); s scanner.nextInt() scanner.nextInt scanner int answer = 0; answer 0 for (int x = 0; x <= k; x++)
            answer += (s - x + 1) - Math.min(s - x + 1, Math.max(0, ((s - x - k) * 2))); int x = 0; int x = 0; x 0 x <= k x k x++ x++ x answer += (s - x + 1) - Math.min(s - x + 1, Math.max(0, ((s - x - k) * 2))); answer += (s - x + 1) - Math.min(s - x + 1, Math.max(0, ((s - x - k) * 2))) answer (s - x + 1) - Math.min(s - x + 1, Math.max(0, ((s - x - k) * 2))) (s - x + 1) s - x s x 1 Math.min(s - x + 1, Math.max(0, ((s - x - k) * 2))) Math.min Math s - x + 1 s - x s x 1 Math.max(0, ((s - x - k) * 2)) Math.max Math 0 ((s - x - k) * 2) (s - x - k) s - x - k s x k 2 System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main {
    private static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int k = scanner.nextInt();
        int s = scanner.nextInt();
        int answer = 0;
        for (int x = 0; x <= k; x++)
            answer += (s - x + 1) - Math.min(s - x + 1, Math.max(0, ((s - x - k) * 2)));
        System.out.println(answer);
    }
} public class Main {
    private static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int k = scanner.nextInt();
        int s = scanner.nextInt();
        int answer = 0;
        for (int x = 0; x <= k; x++)
            answer += (s - x + 1) - Math.min(s - x + 1, Math.max(0, ((s - x - k) * 2)));
        System.out.println(answer);
    }
} Main
import java.util.Scanner;

public class Main {
    private static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int k = scanner.nextInt();
        int s = scanner.nextInt();
        int answer = 0;
        for (int x = 0; x <= k; x++)
            answer += (s - x + 1) - Math.min(s - x + 1, Math.max(0, ((s - x - k) * 2)));
        System.out.println(answer);
    }
}