import java.util.*;

// UVa 11504

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;
		for (int x = 0; x <= k; x++) {
			for (int y = x; y <= k; y++) {
				int z = s - y - x;
				if (y <= z && z <= k) {
					if (x == y && y == z && x == z) {
						answer += 1;
					} else if (x == y || y == z || x == z) {
						answer += 3;
					} else {
						answer += 6;
					}
				}
			}
		}
		System.out.println(answer);
	}
} import java.util.*; util.* java 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;
		for (int x = 0; x <= k; x++) {
			for (int y = x; y <= k; y++) {
				int z = s - y - x;
				if (y <= z && z <= k) {
					if (x == y && y == z && x == z) {
						answer += 1;
					} else if (x == y || y == z || x == z) {
						answer += 3;
					} else {
						answer += 6;
					}
				}
			}
		}
		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;
		for (int x = 0; x <= k; x++) {
			for (int y = x; y <= k; y++) {
				int z = s - y - x;
				if (y <= z && z <= k) {
					if (x == y && y == z && x == z) {
						answer += 1;
					} else if (x == y || y == z || x == z) {
						answer += 3;
					} else {
						answer += 6;
					}
				}
			}
		}
		System.out.println(answer);
	} main {
		Scanner in = new Scanner(System.in);
		
		int k = in.nextInt();
		int s = in.nextInt();
		
		int answer = 0;
		for (int x = 0; x <= k; x++) {
			for (int y = x; y <= k; y++) {
				int z = s - y - x;
				if (y <= z && z <= k) {
					if (x == y && y == z && x == z) {
						answer += 1;
					} else if (x == y || y == z || x == z) {
						answer += 3;
					} else {
						answer += 6;
					}
				}
			}
		}
		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 for (int x = 0; x <= k; x++) {
			for (int y = x; y <= k; y++) {
				int z = s - y - x;
				if (y <= z && z <= k) {
					if (x == y && y == z && x == z) {
						answer += 1;
					} else if (x == y || y == z || x == z) {
						answer += 3;
					} else {
						answer += 6;
					}
				}
			}
		} int x = 0; int x = 0; x 0 x <= k x k x++ x++ x {
			for (int y = x; y <= k; y++) {
				int z = s - y - x;
				if (y <= z && z <= k) {
					if (x == y && y == z && x == z) {
						answer += 1;
					} else if (x == y || y == z || x == z) {
						answer += 3;
					} else {
						answer += 6;
					}
				}
			}
		} {
			for (int y = x; y <= k; y++) {
				int z = s - y - x;
				if (y <= z && z <= k) {
					if (x == y && y == z && x == z) {
						answer += 1;
					} else if (x == y || y == z || x == z) {
						answer += 3;
					} else {
						answer += 6;
					}
				}
			}
		} for (int y = x; y <= k; y++) {
				int z = s - y - x;
				if (y <= z && z <= k) {
					if (x == y && y == z && x == z) {
						answer += 1;
					} else if (x == y || y == z || x == z) {
						answer += 3;
					} else {
						answer += 6;
					}
				}
			} int y = x; int y = x; y x y <= k y k y++ y++ y {
				int z = s - y - x;
				if (y <= z && z <= k) {
					if (x == y && y == z && x == z) {
						answer += 1;
					} else if (x == y || y == z || x == z) {
						answer += 3;
					} else {
						answer += 6;
					}
				}
			} {
				int z = s - y - x;
				if (y <= z && z <= k) {
					if (x == y && y == z && x == z) {
						answer += 1;
					} else if (x == y || y == z || x == z) {
						answer += 3;
					} else {
						answer += 6;
					}
				}
			} int z = s - y - x; z s - y - x s - y - x s y x if (y <= z && z <= k) {
					if (x == y && y == z && x == z) {
						answer += 1;
					} else if (x == y || y == z || x == z) {
						answer += 3;
					} else {
						answer += 6;
					}
				} y <= z && z <= k y <= z y z z <= k z k {
					if (x == y && y == z && x == z) {
						answer += 1;
					} else if (x == y || y == z || x == z) {
						answer += 3;
					} else {
						answer += 6;
					}
				} if (x == y && y == z && x == z) {
						answer += 1;
					} else if (x == y || y == z || x == z) {
						answer += 3;
					} else {
						answer += 6;
					} x == y && y == z && x == z x == y && y == z && x == z x == y x y y == z y z x == z x z {
						answer += 1;
					} answer += 1 answer 1 if (x == y || y == z || x == z) {
						answer += 3;
					} else {
						answer += 6;
					} x == y || y == z || x == z x == y || y == z || x == z x == y x y y == z y z x == z x z {
						answer += 3;
					} answer += 3 answer 3 {
						answer += 6;
					} answer += 6 answer 6 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;
		for (int x = 0; x <= k; x++) {
			for (int y = x; y <= k; y++) {
				int z = s - y - x;
				if (y <= z && z <= k) {
					if (x == y && y == z && x == z) {
						answer += 1;
					} else if (x == y || y == z || x == z) {
						answer += 3;
					} else {
						answer += 6;
					}
				}
			}
		}
		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;
		for (int x = 0; x <= k; x++) {
			for (int y = x; y <= k; y++) {
				int z = s - y - x;
				if (y <= z && z <= k) {
					if (x == y && y == z && x == z) {
						answer += 1;
					} else if (x == y || y == z || x == z) {
						answer += 3;
					} else {
						answer += 6;
					}
				}
			}
		}
		System.out.println(answer);
	}
} Main
import java.util.*;

// UVa 11504

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;
		for (int x = 0; x <= k; x++) {
			for (int y = x; y <= k; y++) {
				int z = s - y - x;
				if (y <= z && z <= k) {
					if (x == y && y == z && x == z) {
						answer += 1;
					} else if (x == y || y == z || x == z) {
						answer += 3;
					} else {
						answer += 6;
					}
				}
			}
		}
		System.out.println(answer);
	}
}