import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);

		int K = s.nextInt();
		int S = s.nextInt();

		int answer = 0;
		for (int x = 0; x <= K; x++) {
			if (x > S)
				break;
			for (int y = 0; y <= K; y++) {
				if (x + y > S)
					break;

				int z = S - x - y;
				if(z<=K) {
					answer ++;
				}
				/*
				for (int z = 0; z <= K; z++) {
					if (x + y + z > S)
						break;

					if(x+y+z == S) {
						answer++;
					}

				}
				*/
			}
		}

		System.out.println(answer);

	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);

		int K = s.nextInt();
		int S = s.nextInt();

		int answer = 0;
		for (int x = 0; x <= K; x++) {
			if (x > S)
				break;
			for (int y = 0; y <= K; y++) {
				if (x + y > S)
					break;

				int z = S - x - y;
				if(z<=K) {
					answer ++;
				}
				/*
				for (int z = 0; z <= K; z++) {
					if (x + y + z > S)
						break;

					if(x+y+z == S) {
						answer++;
					}

				}
				*/
			}
		}

		System.out.println(answer);

	}

} Main public static void main(String[] args) {
		Scanner s = new Scanner(System.in);

		int K = s.nextInt();
		int S = s.nextInt();

		int answer = 0;
		for (int x = 0; x <= K; x++) {
			if (x > S)
				break;
			for (int y = 0; y <= K; y++) {
				if (x + y > S)
					break;

				int z = S - x - y;
				if(z<=K) {
					answer ++;
				}
				/*
				for (int z = 0; z <= K; z++) {
					if (x + y + z > S)
						break;

					if(x+y+z == S) {
						answer++;
					}

				}
				*/
			}
		}

		System.out.println(answer);

	} main {
		Scanner s = new Scanner(System.in);

		int K = s.nextInt();
		int S = s.nextInt();

		int answer = 0;
		for (int x = 0; x <= K; x++) {
			if (x > S)
				break;
			for (int y = 0; y <= K; y++) {
				if (x + y > S)
					break;

				int z = S - x - y;
				if(z<=K) {
					answer ++;
				}
				/*
				for (int z = 0; z <= K; z++) {
					if (x + y + z > S)
						break;

					if(x+y+z == S) {
						answer++;
					}

				}
				*/
			}
		}

		System.out.println(answer);

	} Scanner s = new Scanner(System.in); s new Scanner(System.in) int K = s.nextInt(); K s.nextInt() s.nextInt s int S = s.nextInt(); S s.nextInt() s.nextInt s int answer = 0; answer 0 for (int x = 0; x <= K; x++) {
			if (x > S)
				break;
			for (int y = 0; y <= K; y++) {
				if (x + y > S)
					break;

				int z = S - x - y;
				if(z<=K) {
					answer ++;
				}
				/*
				for (int z = 0; z <= K; z++) {
					if (x + y + z > S)
						break;

					if(x+y+z == S) {
						answer++;
					}

				}
				*/
			}
		} int x = 0; int x = 0; x 0 x <= K x K x++ x++ x {
			if (x > S)
				break;
			for (int y = 0; y <= K; y++) {
				if (x + y > S)
					break;

				int z = S - x - y;
				if(z<=K) {
					answer ++;
				}
				/*
				for (int z = 0; z <= K; z++) {
					if (x + y + z > S)
						break;

					if(x+y+z == S) {
						answer++;
					}

				}
				*/
			}
		} {
			if (x > S)
				break;
			for (int y = 0; y <= K; y++) {
				if (x + y > S)
					break;

				int z = S - x - y;
				if(z<=K) {
					answer ++;
				}
				/*
				for (int z = 0; z <= K; z++) {
					if (x + y + z > S)
						break;

					if(x+y+z == S) {
						answer++;
					}

				}
				*/
			}
		} if (x > S)
				break; x > S x S break; for (int y = 0; y <= K; y++) {
				if (x + y > S)
					break;

				int z = S - x - y;
				if(z<=K) {
					answer ++;
				}
				/*
				for (int z = 0; z <= K; z++) {
					if (x + y + z > S)
						break;

					if(x+y+z == S) {
						answer++;
					}

				}
				*/
			} int y = 0; int y = 0; y 0 y <= K y K y++ y++ y {
				if (x + y > S)
					break;

				int z = S - x - y;
				if(z<=K) {
					answer ++;
				}
				/*
				for (int z = 0; z <= K; z++) {
					if (x + y + z > S)
						break;

					if(x+y+z == S) {
						answer++;
					}

				}
				*/
			} {
				if (x + y > S)
					break;

				int z = S - x - y;
				if(z<=K) {
					answer ++;
				}
				/*
				for (int z = 0; z <= K; z++) {
					if (x + y + z > S)
						break;

					if(x+y+z == S) {
						answer++;
					}

				}
				*/
			} if (x + y > S)
					break; x + y > S x + y x y S break; int z = S - x - y; z S - x - y S - x - y S x y if(z<=K) {
					answer ++;
				} z<=K z K {
					answer ++;
				} answer ++ answer System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);

		int K = s.nextInt();
		int S = s.nextInt();

		int answer = 0;
		for (int x = 0; x <= K; x++) {
			if (x > S)
				break;
			for (int y = 0; y <= K; y++) {
				if (x + y > S)
					break;

				int z = S - x - y;
				if(z<=K) {
					answer ++;
				}
				/*
				for (int z = 0; z <= K; z++) {
					if (x + y + z > S)
						break;

					if(x+y+z == S) {
						answer++;
					}

				}
				*/
			}
		}

		System.out.println(answer);

	}

} public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);

		int K = s.nextInt();
		int S = s.nextInt();

		int answer = 0;
		for (int x = 0; x <= K; x++) {
			if (x > S)
				break;
			for (int y = 0; y <= K; y++) {
				if (x + y > S)
					break;

				int z = S - x - y;
				if(z<=K) {
					answer ++;
				}
				/*
				for (int z = 0; z <= K; z++) {
					if (x + y + z > S)
						break;

					if(x+y+z == S) {
						answer++;
					}

				}
				*/
			}
		}

		System.out.println(answer);

	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);

		int K = s.nextInt();
		int S = s.nextInt();

		int answer = 0;
		for (int x = 0; x <= K; x++) {
			if (x > S)
				break;
			for (int y = 0; y <= K; y++) {
				if (x + y > S)
					break;

				int z = S - x - y;
				if(z<=K) {
					answer ++;
				}
				/*
				for (int z = 0; z <= K; z++) {
					if (x + y + z > S)
						break;

					if(x+y+z == S) {
						answer++;
					}

				}
				*/
			}
		}

		System.out.println(answer);

	}

}
