import java.util.Scanner;

/**
 * B - Sum of Three Integers<br>
 * https://qiita.com/drken/items/e77685614f3c6bf86f44
 */
public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

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

		int answer = 0;

		if (S > K*3) {
			System.out.println(0);
			return;
		}

		// Z を一定の値に固定した場合で考慮
		for(int i = K; i  >= 0; i--) {
			int tmp1 = S - i;
			if (tmp1 > K + K) {
				break;
			}
			for(int j = K; j >= 0; j--) {
				int tmp2 = tmp1 - j;
				if (tmp2 < 0) {
					continue;
				}else if(tmp2 > K) {
					break;
				}
				answer++;
			}
		}

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

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

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

		int answer = 0;

		if (S > K*3) {
			System.out.println(0);
			return;
		}

		// Z を一定の値に固定した場合で考慮
		for(int i = K; i  >= 0; i--) {
			int tmp1 = S - i;
			if (tmp1 > K + K) {
				break;
			}
			for(int j = K; j >= 0; j--) {
				int tmp2 = tmp1 - j;
				if (tmp2 < 0) {
					continue;
				}else if(tmp2 > K) {
					break;
				}
				answer++;
			}
		}

		System.out.println(answer);
	}
} Main public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

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

		int answer = 0;

		if (S > K*3) {
			System.out.println(0);
			return;
		}

		// Z を一定の値に固定した場合で考慮
		for(int i = K; i  >= 0; i--) {
			int tmp1 = S - i;
			if (tmp1 > K + K) {
				break;
			}
			for(int j = K; j >= 0; j--) {
				int tmp2 = tmp1 - j;
				if (tmp2 < 0) {
					continue;
				}else if(tmp2 > K) {
					break;
				}
				answer++;
			}
		}

		System.out.println(answer);
	} main {

		Scanner in = new Scanner(System.in);

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

		int answer = 0;

		if (S > K*3) {
			System.out.println(0);
			return;
		}

		// Z を一定の値に固定した場合で考慮
		for(int i = K; i  >= 0; i--) {
			int tmp1 = S - i;
			if (tmp1 > K + K) {
				break;
			}
			for(int j = K; j >= 0; j--) {
				int tmp2 = tmp1 - j;
				if (tmp2 < 0) {
					continue;
				}else if(tmp2 > K) {
					break;
				}
				answer++;
			}
		}

		System.out.println(answer);
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) int K = in.nextInt(); K in.nextInt() in.nextInt in int S = in.nextInt(); S in.nextInt() in.nextInt in int answer = 0; answer 0 if (S > K*3) {
			System.out.println(0);
			return;
		} S > K*3 S K*3 K 3 {
			System.out.println(0);
			return;
		} System.out.println(0) System.out.println System.out System System.out 0 return; for(int i = K; i  >= 0; i--) {
			int tmp1 = S - i;
			if (tmp1 > K + K) {
				break;
			}
			for(int j = K; j >= 0; j--) {
				int tmp2 = tmp1 - j;
				if (tmp2 < 0) {
					continue;
				}else if(tmp2 > K) {
					break;
				}
				answer++;
			}
		} int i = K; int i = K; i K i  >= 0 i 0 i-- i-- i {
			int tmp1 = S - i;
			if (tmp1 > K + K) {
				break;
			}
			for(int j = K; j >= 0; j--) {
				int tmp2 = tmp1 - j;
				if (tmp2 < 0) {
					continue;
				}else if(tmp2 > K) {
					break;
				}
				answer++;
			}
		} {
			int tmp1 = S - i;
			if (tmp1 > K + K) {
				break;
			}
			for(int j = K; j >= 0; j--) {
				int tmp2 = tmp1 - j;
				if (tmp2 < 0) {
					continue;
				}else if(tmp2 > K) {
					break;
				}
				answer++;
			}
		} int tmp1 = S - i; tmp1 S - i S i if (tmp1 > K + K) {
				break;
			} tmp1 > K + K tmp1 K + K K K {
				break;
			} break; for(int j = K; j >= 0; j--) {
				int tmp2 = tmp1 - j;
				if (tmp2 < 0) {
					continue;
				}else if(tmp2 > K) {
					break;
				}
				answer++;
			} int j = K; int j = K; j K j >= 0 j 0 j-- j-- j {
				int tmp2 = tmp1 - j;
				if (tmp2 < 0) {
					continue;
				}else if(tmp2 > K) {
					break;
				}
				answer++;
			} {
				int tmp2 = tmp1 - j;
				if (tmp2 < 0) {
					continue;
				}else if(tmp2 > K) {
					break;
				}
				answer++;
			} int tmp2 = tmp1 - j; tmp2 tmp1 - j tmp1 j if (tmp2 < 0) {
					continue;
				}else if(tmp2 > K) {
					break;
				} tmp2 < 0 tmp2 0 {
					continue;
				} continue; if(tmp2 > K) {
					break;
				} tmp2 > K tmp2 K {
					break;
				} break; 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 in = new Scanner(System.in);

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

		int answer = 0;

		if (S > K*3) {
			System.out.println(0);
			return;
		}

		// Z を一定の値に固定した場合で考慮
		for(int i = K; i  >= 0; i--) {
			int tmp1 = S - i;
			if (tmp1 > K + K) {
				break;
			}
			for(int j = K; j >= 0; j--) {
				int tmp2 = tmp1 - j;
				if (tmp2 < 0) {
					continue;
				}else if(tmp2 > K) {
					break;
				}
				answer++;
			}
		}

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

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

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

		int answer = 0;

		if (S > K*3) {
			System.out.println(0);
			return;
		}

		// Z を一定の値に固定した場合で考慮
		for(int i = K; i  >= 0; i--) {
			int tmp1 = S - i;
			if (tmp1 > K + K) {
				break;
			}
			for(int j = K; j >= 0; j--) {
				int tmp2 = tmp1 - j;
				if (tmp2 < 0) {
					continue;
				}else if(tmp2 > K) {
					break;
				}
				answer++;
			}
		}

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

/**
 * B - Sum of Three Integers<br>
 * https://qiita.com/drken/items/e77685614f3c6bf86f44
 */
public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

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

		int answer = 0;

		if (S > K*3) {
			System.out.println(0);
			return;
		}

		// Z を一定の値に固定した場合で考慮
		for(int i = K; i  >= 0; i--) {
			int tmp1 = S - i;
			if (tmp1 > K + K) {
				break;
			}
			for(int j = K; j >= 0; j--) {
				int tmp2 = tmp1 - j;
				if (tmp2 < 0) {
					continue;
				}else if(tmp2 > K) {
					break;
				}
				answer++;
			}
		}

		System.out.println(answer);
	}
}
