import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();

		Scanner sc = new Scanner(System.in);
		main.solve(sc);
		sc.close();
	}

	void solve(Scanner sc) {
		int K = sc.nextInt();
		int S = sc.nextInt();

		int count = 0;

		for (int x = 0; x <= K; x++) {
			for (int y = 0; y <= K; y++) {
				if (S - x - y <= K && S >= x + y) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Main main = new Main();

		Scanner sc = new Scanner(System.in);
		main.solve(sc);
		sc.close();
	}

	void solve(Scanner sc) {
		int K = sc.nextInt();
		int S = sc.nextInt();

		int count = 0;

		for (int x = 0; x <= K; x++) {
			for (int y = 0; y <= K; y++) {
				if (S - x - y <= K && S >= x + y) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
} Main public static void main(String[] args) {
		Main main = new Main();

		Scanner sc = new Scanner(System.in);
		main.solve(sc);
		sc.close();
	} main {
		Main main = new Main();

		Scanner sc = new Scanner(System.in);
		main.solve(sc);
		sc.close();
	} Main main = new Main(); main new Main() Scanner sc = new Scanner(System.in); sc new Scanner(System.in) main.solve(sc) main.solve main sc sc.close() sc.close sc String[] args args void solve(Scanner sc) {
		int K = sc.nextInt();
		int S = sc.nextInt();

		int count = 0;

		for (int x = 0; x <= K; x++) {
			for (int y = 0; y <= K; y++) {
				if (S - x - y <= K && S >= x + y) {
					count++;
				}
			}
		}
		System.out.println(count);
	} solve {
		int K = sc.nextInt();
		int S = sc.nextInt();

		int count = 0;

		for (int x = 0; x <= K; x++) {
			for (int y = 0; y <= K; y++) {
				if (S - x - y <= K && S >= x + y) {
					count++;
				}
			}
		}
		System.out.println(count);
	} int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc int S = sc.nextInt(); S sc.nextInt() sc.nextInt sc int count = 0; count 0 for (int x = 0; x <= K; x++) {
			for (int y = 0; y <= K; y++) {
				if (S - x - y <= K && S >= x + y) {
					count++;
				}
			}
		} int x = 0; int x = 0; x 0 x <= K x K x++ x++ x {
			for (int y = 0; y <= K; y++) {
				if (S - x - y <= K && S >= x + y) {
					count++;
				}
			}
		} {
			for (int y = 0; y <= K; y++) {
				if (S - x - y <= K && S >= x + y) {
					count++;
				}
			}
		} for (int y = 0; y <= K; y++) {
				if (S - x - y <= K && S >= x + y) {
					count++;
				}
			} int y = 0; int y = 0; y 0 y <= K y K y++ y++ y {
				if (S - x - y <= K && S >= x + y) {
					count++;
				}
			} {
				if (S - x - y <= K && S >= x + y) {
					count++;
				}
			} if (S - x - y <= K && S >= x + y) {
					count++;
				} S - x - y <= K && S >= x + y S - x - y <= K S - x - y S - x - y S x y K S >= x + y S x + y x y {
					count++;
				} count++ count System.out.println(count) System.out.println System.out System System.out count Scanner sc sc public class Main {
	public static void main(String[] args) {
		Main main = new Main();

		Scanner sc = new Scanner(System.in);
		main.solve(sc);
		sc.close();
	}

	void solve(Scanner sc) {
		int K = sc.nextInt();
		int S = sc.nextInt();

		int count = 0;

		for (int x = 0; x <= K; x++) {
			for (int y = 0; y <= K; y++) {
				if (S - x - y <= K && S >= x + y) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
} public class Main {
	public static void main(String[] args) {
		Main main = new Main();

		Scanner sc = new Scanner(System.in);
		main.solve(sc);
		sc.close();
	}

	void solve(Scanner sc) {
		int K = sc.nextInt();
		int S = sc.nextInt();

		int count = 0;

		for (int x = 0; x <= K; x++) {
			for (int y = 0; y <= K; y++) {
				if (S - x - y <= K && S >= x + y) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();

		Scanner sc = new Scanner(System.in);
		main.solve(sc);
		sc.close();
	}

	void solve(Scanner sc) {
		int K = sc.nextInt();
		int S = sc.nextInt();

		int count = 0;

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