import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int k = scanner.nextInt();
		int s = scanner.nextInt();

		int ans = 0;
		for (int x = 0; x <= k; x++) {
			for (int y = 0; y <= k; y++) {
				if (0 <= s - x - y && s - x - y <= k) {
					ans++;
				}
			}
		}

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

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int k = scanner.nextInt();
		int s = scanner.nextInt();

		int ans = 0;
		for (int x = 0; x <= k; x++) {
			for (int y = 0; y <= k; y++) {
				if (0 <= s - x - y && s - x - y <= k) {
					ans++;
				}
			}
		}

		System.out.println(ans);
	}
} Main @SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int k = scanner.nextInt();
		int s = scanner.nextInt();

		int ans = 0;
		for (int x = 0; x <= k; x++) {
			for (int y = 0; y <= k; y++) {
				if (0 <= s - x - y && s - x - y <= k) {
					ans++;
				}
			}
		}

		System.out.println(ans);
	} main {
		Scanner scanner = new Scanner(System.in);
		int k = scanner.nextInt();
		int s = scanner.nextInt();

		int ans = 0;
		for (int x = 0; x <= k; x++) {
			for (int y = 0; y <= k; y++) {
				if (0 <= s - x - y && s - x - y <= k) {
					ans++;
				}
			}
		}

		System.out.println(ans);
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int k = scanner.nextInt(); k scanner.nextInt() scanner.nextInt scanner int s = scanner.nextInt(); s scanner.nextInt() scanner.nextInt scanner int ans = 0; ans 0 for (int x = 0; x <= k; x++) {
			for (int y = 0; y <= k; y++) {
				if (0 <= s - x - y && s - x - y <= k) {
					ans++;
				}
			}
		} int x = 0; int x = 0; x 0 x <= k x k x++ x++ x {
			for (int y = 0; y <= k; y++) {
				if (0 <= s - x - y && s - x - y <= k) {
					ans++;
				}
			}
		} {
			for (int y = 0; y <= k; y++) {
				if (0 <= s - x - y && s - x - y <= k) {
					ans++;
				}
			}
		} for (int y = 0; y <= k; y++) {
				if (0 <= s - x - y && s - x - y <= k) {
					ans++;
				}
			} int y = 0; int y = 0; y 0 y <= k y k y++ y++ y {
				if (0 <= s - x - y && s - x - y <= k) {
					ans++;
				}
			} {
				if (0 <= s - x - y && s - x - y <= k) {
					ans++;
				}
			} if (0 <= s - x - y && s - x - y <= k) {
					ans++;
				} 0 <= s - x - y && s - x - y <= k 0 <= s - x - y 0 s - x - y s - x - y s x y s - x - y <= k s - x - y s - x - y s x y k {
					ans++;
				} ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String args[] args public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int k = scanner.nextInt();
		int s = scanner.nextInt();

		int ans = 0;
		for (int x = 0; x <= k; x++) {
			for (int y = 0; y <= k; y++) {
				if (0 <= s - x - y && s - x - y <= k) {
					ans++;
				}
			}
		}

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

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int k = scanner.nextInt();
		int s = scanner.nextInt();

		int ans = 0;
		for (int x = 0; x <= k; x++) {
			for (int y = 0; y <= k; y++) {
				if (0 <= s - x - y && s - x - y <= k) {
					ans++;
				}
			}
		}

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

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int k = scanner.nextInt();
		int s = scanner.nextInt();

		int ans = 0;
		for (int x = 0; x <= k; x++) {
			for (int y = 0; y <= k; y++) {
				if (0 <= s - x - y && s - x - y <= k) {
					ans++;
				}
			}
		}

		System.out.println(ans);
	}
}