import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int maxValue = scanner.nextInt();
			int S = scanner.nextInt();

			int cnt = 0;
			for (int x = 0; x <= maxValue; x++) {
				for (int y = 0; y <= maxValue; y++) {
					int z = S - x - y;
					if (z >= 0 && z <= maxValue) cnt++;
				}
			}
			System.out.println(cnt);

		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int maxValue = scanner.nextInt();
			int S = scanner.nextInt();

			int cnt = 0;
			for (int x = 0; x <= maxValue; x++) {
				for (int y = 0; y <= maxValue; y++) {
					int z = S - x - y;
					if (z >= 0 && z <= maxValue) cnt++;
				}
			}
			System.out.println(cnt);

		}
	}
} Main public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int maxValue = scanner.nextInt();
			int S = scanner.nextInt();

			int cnt = 0;
			for (int x = 0; x <= maxValue; x++) {
				for (int y = 0; y <= maxValue; y++) {
					int z = S - x - y;
					if (z >= 0 && z <= maxValue) cnt++;
				}
			}
			System.out.println(cnt);

		}
	} main {
		try (Scanner scanner = new Scanner(System.in)) {
			int maxValue = scanner.nextInt();
			int S = scanner.nextInt();

			int cnt = 0;
			for (int x = 0; x <= maxValue; x++) {
				for (int y = 0; y <= maxValue; y++) {
					int z = S - x - y;
					if (z >= 0 && z <= maxValue) cnt++;
				}
			}
			System.out.println(cnt);

		}
	} try (Scanner scanner = new Scanner(System.in)) {
			int maxValue = scanner.nextInt();
			int S = scanner.nextInt();

			int cnt = 0;
			for (int x = 0; x <= maxValue; x++) {
				for (int y = 0; y <= maxValue; y++) {
					int z = S - x - y;
					if (z >= 0 && z <= maxValue) cnt++;
				}
			}
			System.out.println(cnt);

		} {
			int maxValue = scanner.nextInt();
			int S = scanner.nextInt();

			int cnt = 0;
			for (int x = 0; x <= maxValue; x++) {
				for (int y = 0; y <= maxValue; y++) {
					int z = S - x - y;
					if (z >= 0 && z <= maxValue) cnt++;
				}
			}
			System.out.println(cnt);

		} Scanner scanner = new Scanner(System.in) Scanner scanner = new Scanner(System.in) new Scanner(System.in) int maxValue = scanner.nextInt(); maxValue scanner.nextInt() scanner.nextInt scanner int S = scanner.nextInt(); S scanner.nextInt() scanner.nextInt scanner int cnt = 0; cnt 0 for (int x = 0; x <= maxValue; x++) {
				for (int y = 0; y <= maxValue; y++) {
					int z = S - x - y;
					if (z >= 0 && z <= maxValue) cnt++;
				}
			} int x = 0; int x = 0; x 0 x <= maxValue x maxValue x++ x++ x {
				for (int y = 0; y <= maxValue; y++) {
					int z = S - x - y;
					if (z >= 0 && z <= maxValue) cnt++;
				}
			} {
				for (int y = 0; y <= maxValue; y++) {
					int z = S - x - y;
					if (z >= 0 && z <= maxValue) cnt++;
				}
			} for (int y = 0; y <= maxValue; y++) {
					int z = S - x - y;
					if (z >= 0 && z <= maxValue) cnt++;
				} int y = 0; int y = 0; y 0 y <= maxValue y maxValue y++ y++ y {
					int z = S - x - y;
					if (z >= 0 && z <= maxValue) cnt++;
				} {
					int z = S - x - y;
					if (z >= 0 && z <= maxValue) cnt++;
				} int z = S - x - y; z S - x - y S - x - y S x y if (z >= 0 && z <= maxValue) cnt++; z >= 0 && z <= maxValue z >= 0 z 0 z <= maxValue z maxValue cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int maxValue = scanner.nextInt();
			int S = scanner.nextInt();

			int cnt = 0;
			for (int x = 0; x <= maxValue; x++) {
				for (int y = 0; y <= maxValue; y++) {
					int z = S - x - y;
					if (z >= 0 && z <= maxValue) cnt++;
				}
			}
			System.out.println(cnt);

		}
	}
} public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int maxValue = scanner.nextInt();
			int S = scanner.nextInt();

			int cnt = 0;
			for (int x = 0; x <= maxValue; x++) {
				for (int y = 0; y <= maxValue; y++) {
					int z = S - x - y;
					if (z >= 0 && z <= maxValue) cnt++;
				}
			}
			System.out.println(cnt);

		}
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int maxValue = scanner.nextInt();
			int S = scanner.nextInt();

			int cnt = 0;
			for (int x = 0; x <= maxValue; x++) {
				for (int y = 0; y <= maxValue; y++) {
					int z = S - x - y;
					if (z >= 0 && z <= maxValue) cnt++;
				}
			}
			System.out.println(cnt);

		}
	}
}