import java.util.*;
import java.io.*;

class Main {

	void solve() {
		
		int k = inint(), s = inint();
		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) && x + y + z == s) count++;
			}
		}
		
		out.println(count);

	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

	public int inint() {
		return in.nextInt();
	}

	public long inlong() {
		return in.nextLong();
	}

	public String instr() {
		return in.next();
	}

	public char inchar() {
		return in.next().charAt(0);
	}

	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

} import java.util.*; util.* java import java.io.*; io.* java class Main {

	void solve() {
		
		int k = inint(), s = inint();
		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) && x + y + z == s) count++;
			}
		}
		
		out.println(count);

	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

	public int inint() {
		return in.nextInt();
	}

	public long inlong() {
		return in.nextLong();
	}

	public String instr() {
		return in.next();
	}

	public char inchar() {
		return in.next().charAt(0);
	}

	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

} Main public static Scanner in = new Scanner(System.in); in new Scanner(System.in) public static PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) void solve() {
		
		int k = inint(), s = inint();
		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) && x + y + z == s) count++;
			}
		}
		
		out.println(count);

	} solve {
		
		int k = inint(), s = inint();
		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) && x + y + z == s) count++;
			}
		}
		
		out.println(count);

	} int k = inint() k inint() inint s = inint(); s inint() inint 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) && x + y + z == s) count++;
			}
		} 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) && x + y + z == s) count++;
			}
		} {
			for (int y=0; y<=k; y++) {
				int z = s - x - y;
				if ((0 <= z && z <= k) && x + y + z == s) count++;
			}
		} for (int y=0; y<=k; y++) {
				int z = s - x - y;
				if ((0 <= z && z <= k) && x + y + z == s) count++;
			} 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) && x + y + z == s) count++;
			} {
				int z = s - x - y;
				if ((0 <= z && z <= k) && x + y + z == s) count++;
			} int z = s - x - y; z s - x - y s - x - y s x y if ((0 <= z && z <= k) && x + y + z == s) count++; (0 <= z && z <= k) && x + y + z == s (0 <= z && z <= k) 0 <= z 0 z z <= k z k x + y + z == s x + y + z x + y + z x y z s count++ count out.println(count) out.println out count public static void main(String[] args) {
		new Main().solve();
		out.flush();
	} main {
		new Main().solve();
		out.flush();
	} new Main().solve() new Main().solve new Main() out.flush() out.flush out String[] args args public int inint() {
		return in.nextInt();
	} inint {
		return in.nextInt();
	} return in.nextInt(); in.nextInt() in.nextInt in public long inlong() {
		return in.nextLong();
	} inlong {
		return in.nextLong();
	} return in.nextLong(); in.nextLong() in.nextLong in public String instr() {
		return in.next();
	} instr {
		return in.next();
	} return in.next(); in.next() in.next in public char inchar() {
		return in.next().charAt(0);
	} inchar {
		return in.next().charAt(0);
	} return in.next().charAt(0); in.next().charAt(0) in.next().charAt in.next() in.next in 0 public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	} inintar {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	} int[] a = new int[num]; a new int[num] num for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		} int i=0; int i=0; i 0 i<num i num i++ i++ i {
			a[i] = in.nextInt();
		} {
			a[i] = in.nextInt();
		} a[i] = in.nextInt() a[i] a i in.nextInt() in.nextInt in return a; a int num num public char[] incharar() {
		return in.next().toCharArray();
	} incharar {
		return in.next().toCharArray();
	} return in.next().toCharArray(); in.next().toCharArray() in.next().toCharArray in.next() in.next in
import java.util.*;
import java.io.*;

class Main {

	void solve() {
		
		int k = inint(), s = inint();
		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) && x + y + z == s) count++;
			}
		}
		
		out.println(count);

	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

	public int inint() {
		return in.nextInt();
	}

	public long inlong() {
		return in.nextLong();
	}

	public String instr() {
		return in.next();
	}

	public char inchar() {
		return in.next().charAt(0);
	}

	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

}