import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = Integer.parseInt(sc.next());
		int s = Integer.parseInt(sc.next());

		int count = 0;

		for (int x = 0; x <= k; x++) {
			for (int y = 0; y <= k; y++) {
				int z = s - x - y;
				if (0 <= z && z <= k) {
					count++;
				} else if(z < 0){
					break;
				}
			}
		}

		System.out.println(count);
		sc.close();
	}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = Integer.parseInt(sc.next());
		int s = Integer.parseInt(sc.next());

		int count = 0;

		for (int x = 0; x <= k; x++) {
			for (int y = 0; y <= k; y++) {
				int z = s - x - y;
				if (0 <= z && z <= k) {
					count++;
				} else if(z < 0){
					break;
				}
			}
		}

		System.out.println(count);
		sc.close();
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = Integer.parseInt(sc.next());
		int s = Integer.parseInt(sc.next());

		int count = 0;

		for (int x = 0; x <= k; x++) {
			for (int y = 0; y <= k; y++) {
				int z = s - x - y;
				if (0 <= z && z <= k) {
					count++;
				} else if(z < 0){
					break;
				}
			}
		}

		System.out.println(count);
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int k = Integer.parseInt(sc.next());
		int s = Integer.parseInt(sc.next());

		int count = 0;

		for (int x = 0; x <= k; x++) {
			for (int y = 0; y <= k; y++) {
				int z = s - x - y;
				if (0 <= z && z <= k) {
					count++;
				} else if(z < 0){
					break;
				}
			}
		}

		System.out.println(count);
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int k = Integer.parseInt(sc.next()); k Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int s = Integer.parseInt(sc.next()); s Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int count = 0; count 0 for (int x = 0; x <= k; x++) {
			for (int y = 0; y <= k; y++) {
				int z = s - x - y;
				if (0 <= z && z <= k) {
					count++;
				} else if(z < 0){
					break;
				}
			}
		} int x = 0; int x = 0; x 0 x <= k x k x++ x++ x {
			for (int y = 0; y <= k; y++) {
				int z = s - x - y;
				if (0 <= z && z <= k) {
					count++;
				} else if(z < 0){
					break;
				}
			}
		} {
			for (int y = 0; y <= k; y++) {
				int z = s - x - y;
				if (0 <= z && z <= k) {
					count++;
				} else if(z < 0){
					break;
				}
			}
		} for (int y = 0; y <= k; y++) {
				int z = s - x - y;
				if (0 <= z && z <= k) {
					count++;
				} else if(z < 0){
					break;
				}
			} int y = 0; int y = 0; y 0 y <= k y k y++ y++ y {
				int z = s - x - y;
				if (0 <= z && z <= k) {
					count++;
				} else if(z < 0){
					break;
				}
			} {
				int z = s - x - y;
				if (0 <= z && z <= k) {
					count++;
				} else if(z < 0){
					break;
				}
			} int z = s - x - y; z s - x - y s - x - y s x y if (0 <= z && z <= k) {
					count++;
				} else if(z < 0){
					break;
				} 0 <= z && z <= k 0 <= z 0 z z <= k z k {
					count++;
				} count++ count if(z < 0){
					break;
				} z < 0 z 0 {
					break;
				} break; System.out.println(count) System.out.println System.out System System.out count sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = Integer.parseInt(sc.next());
		int s = Integer.parseInt(sc.next());

		int count = 0;

		for (int x = 0; x <= k; x++) {
			for (int y = 0; y <= k; y++) {
				int z = s - x - y;
				if (0 <= z && z <= k) {
					count++;
				} else if(z < 0){
					break;
				}
			}
		}

		System.out.println(count);
		sc.close();
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = Integer.parseInt(sc.next());
		int s = Integer.parseInt(sc.next());

		int count = 0;

		for (int x = 0; x <= k; x++) {
			for (int y = 0; y <= k; y++) {
				int z = s - x - y;
				if (0 <= z && z <= k) {
					count++;
				} else if(z < 0){
					break;
				}
			}
		}

		System.out.println(count);
		sc.close();
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = Integer.parseInt(sc.next());
		int s = Integer.parseInt(sc.next());

		int count = 0;

		for (int x = 0; x <= k; x++) {
			for (int y = 0; y <= k; y++) {
				int z = s - x - y;
				if (0 <= z && z <= k) {
					count++;
				} else if(z < 0){
					break;
				}
			}
		}

		System.out.println(count);
		sc.close();
	}

}
