import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int k = scanner.nextInt(), s = scanner.nextInt();
			int count = 0;
			for (int x = 0; x <= Math.min(k, s); x++) {
				for (int y = Math.max(0, s - x - k); y <= Math.min(k, s - x); y++) {
					int z = s - x - y;
					if ((z >= 0) && (z <= k)) {
						count++;
					}
				}
			}
			System.out.println(count);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int k = scanner.nextInt(), s = scanner.nextInt();
			int count = 0;
			for (int x = 0; x <= Math.min(k, s); x++) {
				for (int y = Math.max(0, s - x - k); y <= Math.min(k, s - x); y++) {
					int z = s - x - y;
					if ((z >= 0) && (z <= k)) {
						count++;
					}
				}
			}
			System.out.println(count);
		}
	}
} Main public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int k = scanner.nextInt(), s = scanner.nextInt();
			int count = 0;
			for (int x = 0; x <= Math.min(k, s); x++) {
				for (int y = Math.max(0, s - x - k); y <= Math.min(k, s - x); y++) {
					int z = s - x - y;
					if ((z >= 0) && (z <= k)) {
						count++;
					}
				}
			}
			System.out.println(count);
		}
	} main {
		try (Scanner scanner = new Scanner(System.in)) {
			int k = scanner.nextInt(), s = scanner.nextInt();
			int count = 0;
			for (int x = 0; x <= Math.min(k, s); x++) {
				for (int y = Math.max(0, s - x - k); y <= Math.min(k, s - x); y++) {
					int z = s - x - y;
					if ((z >= 0) && (z <= k)) {
						count++;
					}
				}
			}
			System.out.println(count);
		}
	} try (Scanner scanner = new Scanner(System.in)) {
			int k = scanner.nextInt(), s = scanner.nextInt();
			int count = 0;
			for (int x = 0; x <= Math.min(k, s); x++) {
				for (int y = Math.max(0, s - x - k); y <= Math.min(k, s - x); y++) {
					int z = s - x - y;
					if ((z >= 0) && (z <= k)) {
						count++;
					}
				}
			}
			System.out.println(count);
		} {
			int k = scanner.nextInt(), s = scanner.nextInt();
			int count = 0;
			for (int x = 0; x <= Math.min(k, s); x++) {
				for (int y = Math.max(0, s - x - k); y <= Math.min(k, s - x); y++) {
					int z = s - x - y;
					if ((z >= 0) && (z <= k)) {
						count++;
					}
				}
			}
			System.out.println(count);
		} Scanner scanner = new Scanner(System.in) Scanner scanner = new Scanner(System.in) new Scanner(System.in) int k = scanner.nextInt() k scanner.nextInt() scanner.nextInt scanner s = scanner.nextInt(); s scanner.nextInt() scanner.nextInt scanner int count = 0; count 0 for (int x = 0; x <= Math.min(k, s); x++) {
				for (int y = Math.max(0, s - x - k); y <= Math.min(k, s - x); y++) {
					int z = s - x - y;
					if ((z >= 0) && (z <= k)) {
						count++;
					}
				}
			} int x = 0; int x = 0; x 0 x <= Math.min(k, s) x Math.min(k, s) Math.min Math k s x++ x++ x {
				for (int y = Math.max(0, s - x - k); y <= Math.min(k, s - x); y++) {
					int z = s - x - y;
					if ((z >= 0) && (z <= k)) {
						count++;
					}
				}
			} {
				for (int y = Math.max(0, s - x - k); y <= Math.min(k, s - x); y++) {
					int z = s - x - y;
					if ((z >= 0) && (z <= k)) {
						count++;
					}
				}
			} for (int y = Math.max(0, s - x - k); y <= Math.min(k, s - x); y++) {
					int z = s - x - y;
					if ((z >= 0) && (z <= k)) {
						count++;
					}
				} int y = Math.max(0, s - x - k); int y = Math.max(0, s - x - k); y Math.max(0, s - x - k) Math.max Math 0 s - x - k s - x - k s x k y <= Math.min(k, s - x) y Math.min(k, s - x) Math.min Math k s - x s x y++ y++ y {
					int z = s - x - y;
					if ((z >= 0) && (z <= k)) {
						count++;
					}
				} {
					int z = s - x - y;
					if ((z >= 0) && (z <= k)) {
						count++;
					}
				} int z = s - x - y; z s - x - y s - x - y s x y if ((z >= 0) && (z <= k)) {
						count++;
					} (z >= 0) && (z <= k) (z >= 0) z 0 (z <= k) z k {
						count++;
					} count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int k = scanner.nextInt(), s = scanner.nextInt();
			int count = 0;
			for (int x = 0; x <= Math.min(k, s); x++) {
				for (int y = Math.max(0, s - x - k); y <= Math.min(k, s - x); y++) {
					int z = s - x - y;
					if ((z >= 0) && (z <= k)) {
						count++;
					}
				}
			}
			System.out.println(count);
		}
	}
} public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int k = scanner.nextInt(), s = scanner.nextInt();
			int count = 0;
			for (int x = 0; x <= Math.min(k, s); x++) {
				for (int y = Math.max(0, s - x - k); y <= Math.min(k, s - x); y++) {
					int z = s - x - y;
					if ((z >= 0) && (z <= k)) {
						count++;
					}
				}
			}
			System.out.println(count);
		}
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int k = scanner.nextInt(), s = scanner.nextInt();
			int count = 0;
			for (int x = 0; x <= Math.min(k, s); x++) {
				for (int y = Math.max(0, s - x - k); y <= Math.min(k, s - x); y++) {
					int z = s - x - y;
					if ((z >= 0) && (z <= k)) {
						count++;
					}
				}
			}
			System.out.println(count);
		}
	}
}
