import java.util.Scanner;
import java.util.Stack;

public class Main {

	final int[][] dir = { { -1, -1 }, { -1, 1 }, { 1, -1 }, { 1, 1 } };

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

		int k = readInt(sc);
		int s = readInt(sc);

		int cnt = 0;

		for (int a = 0; a <= k; a++) {
			for (int b = 0; b <= k; b++) {
				int c = s - a - b;
				if (c >= 0 && c <= k) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}

	static int readInt(Scanner sc) {
		return Integer.parseInt(sc.next());
	}

	static double calcDistance(Pair p1, Pair p2) {
		return Math.pow(Math.pow(p1.getX() - p2.getX(), 2) + Math.pow(p1.getY() - p2.getY(), 2), 0.5);
	}

}

class Pair {
	private int x;
	private int y;

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public Pair() {

	}

	public Pair(int x, int y) {
		this.x = x;
		this.y = y;
	}

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

	final int[][] dir = { { -1, -1 }, { -1, 1 }, { 1, -1 }, { 1, 1 } };

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

		int k = readInt(sc);
		int s = readInt(sc);

		int cnt = 0;

		for (int a = 0; a <= k; a++) {
			for (int b = 0; b <= k; b++) {
				int c = s - a - b;
				if (c >= 0 && c <= k) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}

	static int readInt(Scanner sc) {
		return Integer.parseInt(sc.next());
	}

	static double calcDistance(Pair p1, Pair p2) {
		return Math.pow(Math.pow(p1.getX() - p2.getX(), 2) + Math.pow(p1.getY() - p2.getY(), 2), 0.5);
	}

} Main final int[][] dir = { { -1, -1 }, { -1, 1 }, { 1, -1 }, { 1, 1 } }; dir { { -1, -1 }, { -1, 1 }, { 1, -1 }, { 1, 1 } } { -1, -1 } -1 1 -1 1 { -1, 1 } -1 1 1 { 1, -1 } 1 -1 1 { 1, 1 } 1 1 public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int k = readInt(sc);
		int s = readInt(sc);

		int cnt = 0;

		for (int a = 0; a <= k; a++) {
			for (int b = 0; b <= k; b++) {
				int c = s - a - b;
				if (c >= 0 && c <= k) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	} main {
		Scanner sc = new Scanner(System.in);

		int k = readInt(sc);
		int s = readInt(sc);

		int cnt = 0;

		for (int a = 0; a <= k; a++) {
			for (int b = 0; b <= k; b++) {
				int c = s - a - b;
				if (c >= 0 && c <= k) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int k = readInt(sc); k readInt(sc) readInt sc int s = readInt(sc); s readInt(sc) readInt sc int cnt = 0; cnt 0 for (int a = 0; a <= k; a++) {
			for (int b = 0; b <= k; b++) {
				int c = s - a - b;
				if (c >= 0 && c <= k) {
					cnt++;
				}
			}
		} int a = 0; int a = 0; a 0 a <= k a k a++ a++ a {
			for (int b = 0; b <= k; b++) {
				int c = s - a - b;
				if (c >= 0 && c <= k) {
					cnt++;
				}
			}
		} {
			for (int b = 0; b <= k; b++) {
				int c = s - a - b;
				if (c >= 0 && c <= k) {
					cnt++;
				}
			}
		} for (int b = 0; b <= k; b++) {
				int c = s - a - b;
				if (c >= 0 && c <= k) {
					cnt++;
				}
			} int b = 0; int b = 0; b 0 b <= k b k b++ b++ b {
				int c = s - a - b;
				if (c >= 0 && c <= k) {
					cnt++;
				}
			} {
				int c = s - a - b;
				if (c >= 0 && c <= k) {
					cnt++;
				}
			} int c = s - a - b; c s - a - b s - a - b s a b if (c >= 0 && c <= k) {
					cnt++;
				} c >= 0 && c <= k c >= 0 c 0 c <= k c k {
					cnt++;
				} cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args static int readInt(Scanner sc) {
		return Integer.parseInt(sc.next());
	} readInt {
		return Integer.parseInt(sc.next());
	} return Integer.parseInt(sc.next()); Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc Scanner sc sc static double calcDistance(Pair p1, Pair p2) {
		return Math.pow(Math.pow(p1.getX() - p2.getX(), 2) + Math.pow(p1.getY() - p2.getY(), 2), 0.5);
	} calcDistance {
		return Math.pow(Math.pow(p1.getX() - p2.getX(), 2) + Math.pow(p1.getY() - p2.getY(), 2), 0.5);
	} return Math.pow(Math.pow(p1.getX() - p2.getX(), 2) + Math.pow(p1.getY() - p2.getY(), 2), 0.5); Math.pow(Math.pow(p1.getX() - p2.getX(), 2) + Math.pow(p1.getY() - p2.getY(), 2), 0.5) Math.pow Math Math.pow(p1.getX() - p2.getX(), 2) + Math.pow(p1.getY() - p2.getY(), 2) Math.pow(p1.getX() - p2.getX(), 2) Math.pow Math p1.getX() - p2.getX() p1.getX() p1.getX p1 p2.getX() p2.getX p2 2 Math.pow(p1.getY() - p2.getY(), 2) Math.pow Math p1.getY() - p2.getY() p1.getY() p1.getY p1 p2.getY() p2.getY p2 2 0.5 Pair p1 p1 Pair p2 p2 class Pair {
	private int x;
	private int y;

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public Pair() {

	}

	public Pair(int x, int y) {
		this.x = x;
		this.y = y;
	}

} Pair private int x; x private int y; y public int getX() {
		return x;
	} getX {
		return x;
	} return x; x public void setX(int x) {
		this.x = x;
	} setX {
		this.x = x;
	} this.x = x this.x this this.x x int x x public int getY() {
		return y;
	} getY {
		return y;
	} return y; y public void setY(int y) {
		this.y = y;
	} setY {
		this.y = y;
	} this.y = y this.y this this.y y int y y public Pair() {

	} Pair {

	} public Pair(int x, int y) {
		this.x = x;
		this.y = y;
	} Pair {
		this.x = x;
		this.y = y;
	} this.x = x this.x this this.x x this.y = y this.y this this.y y int x x int y y public class Main {

	final int[][] dir = { { -1, -1 }, { -1, 1 }, { 1, -1 }, { 1, 1 } };

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

		int k = readInt(sc);
		int s = readInt(sc);

		int cnt = 0;

		for (int a = 0; a <= k; a++) {
			for (int b = 0; b <= k; b++) {
				int c = s - a - b;
				if (c >= 0 && c <= k) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}

	static int readInt(Scanner sc) {
		return Integer.parseInt(sc.next());
	}

	static double calcDistance(Pair p1, Pair p2) {
		return Math.pow(Math.pow(p1.getX() - p2.getX(), 2) + Math.pow(p1.getY() - p2.getY(), 2), 0.5);
	}

} public class Main {

	final int[][] dir = { { -1, -1 }, { -1, 1 }, { 1, -1 }, { 1, 1 } };

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

		int k = readInt(sc);
		int s = readInt(sc);

		int cnt = 0;

		for (int a = 0; a <= k; a++) {
			for (int b = 0; b <= k; b++) {
				int c = s - a - b;
				if (c >= 0 && c <= k) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}

	static int readInt(Scanner sc) {
		return Integer.parseInt(sc.next());
	}

	static double calcDistance(Pair p1, Pair p2) {
		return Math.pow(Math.pow(p1.getX() - p2.getX(), 2) + Math.pow(p1.getY() - p2.getY(), 2), 0.5);
	}

} Main
import java.util.Scanner;
import java.util.Stack;

public class Main {

	final int[][] dir = { { -1, -1 }, { -1, 1 }, { 1, -1 }, { 1, 1 } };

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

		int k = readInt(sc);
		int s = readInt(sc);

		int cnt = 0;

		for (int a = 0; a <= k; a++) {
			for (int b = 0; b <= k; b++) {
				int c = s - a - b;
				if (c >= 0 && c <= k) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}

	static int readInt(Scanner sc) {
		return Integer.parseInt(sc.next());
	}

	static double calcDistance(Pair p1, Pair p2) {
		return Math.pow(Math.pow(p1.getX() - p2.getX(), 2) + Math.pow(p1.getY() - p2.getY(), 2), 0.5);
	}

}

class Pair {
	private int x;
	private int y;

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public Pair() {

	}

	public Pair(int x, int y) {
		this.x = x;
		this.y = y;
	}

}
