import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int K = nextInt();
		int S = nextInt();

		int cnt = 0;
		for(int i=0;i<=K;i++) {
			for(int j=0;j<=K;j++) {
				int num = i+j;
				if(num + K >= S && num <= S) {
					cnt++;
				}else if(num > S) {
					break;
				}
			}
		}

		out.println(cnt);
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

} import java.io.PrintStream; PrintStream java.io import java.util.Scanner; Scanner java.util public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int K = nextInt();
		int S = nextInt();

		int cnt = 0;
		for(int i=0;i<=K;i++) {
			for(int j=0;j<=K;j++) {
				int num = i+j;
				if(num + K >= S && num <= S) {
					cnt++;
				}else if(num > S) {
					break;
				}
			}
		}

		out.println(cnt);
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

} Main static final PrintStream out = System.out; out System.out System System.out static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) static final long Mod = 1000_000_007L; Mod 1000_000_007L public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	} main {
		Main main = new Main();
		main.solve();
		System.exit(0);
	} Main main = new Main(); main new Main() main.solve() main.solve main System.exit(0) System.exit System 0 String[] args args void solve() {
		int K = nextInt();
		int S = nextInt();

		int cnt = 0;
		for(int i=0;i<=K;i++) {
			for(int j=0;j<=K;j++) {
				int num = i+j;
				if(num + K >= S && num <= S) {
					cnt++;
				}else if(num > S) {
					break;
				}
			}
		}

		out.println(cnt);
	} solve {
		int K = nextInt();
		int S = nextInt();

		int cnt = 0;
		for(int i=0;i<=K;i++) {
			for(int j=0;j<=K;j++) {
				int num = i+j;
				if(num + K >= S && num <= S) {
					cnt++;
				}else if(num > S) {
					break;
				}
			}
		}

		out.println(cnt);
	} int K = nextInt(); K nextInt() nextInt int S = nextInt(); S nextInt() nextInt int cnt = 0; cnt 0 for(int i=0;i<=K;i++) {
			for(int j=0;j<=K;j++) {
				int num = i+j;
				if(num + K >= S && num <= S) {
					cnt++;
				}else if(num > S) {
					break;
				}
			}
		} int i=0; int i=0; i 0 i<=K i K i++ i++ i {
			for(int j=0;j<=K;j++) {
				int num = i+j;
				if(num + K >= S && num <= S) {
					cnt++;
				}else if(num > S) {
					break;
				}
			}
		} {
			for(int j=0;j<=K;j++) {
				int num = i+j;
				if(num + K >= S && num <= S) {
					cnt++;
				}else if(num > S) {
					break;
				}
			}
		} for(int j=0;j<=K;j++) {
				int num = i+j;
				if(num + K >= S && num <= S) {
					cnt++;
				}else if(num > S) {
					break;
				}
			} int j=0; int j=0; j 0 j<=K j K j++ j++ j {
				int num = i+j;
				if(num + K >= S && num <= S) {
					cnt++;
				}else if(num > S) {
					break;
				}
			} {
				int num = i+j;
				if(num + K >= S && num <= S) {
					cnt++;
				}else if(num > S) {
					break;
				}
			} int num = i+j; num i+j i j if(num + K >= S && num <= S) {
					cnt++;
				}else if(num > S) {
					break;
				} num + K >= S && num <= S num + K >= S num + K num K S num <= S num S {
					cnt++;
				} cnt++ cnt if(num > S) {
					break;
				} num > S num S {
					break;
				} break; out.println(cnt) out.println out cnt public int nextInt() {
		return Integer.parseInt(next());
	} nextInt {
		return Integer.parseInt(next());
	} return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next public long nextLong() {
		return Long.parseLong(next());
	} nextLong {
		return Long.parseLong(next());
	} return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next public String next() {
		return sc.next();
	} next {
		return sc.next();
	} return sc.next(); sc.next() sc.next sc public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int K = nextInt();
		int S = nextInt();

		int cnt = 0;
		for(int i=0;i<=K;i++) {
			for(int j=0;j<=K;j++) {
				int num = i+j;
				if(num + K >= S && num <= S) {
					cnt++;
				}else if(num > S) {
					break;
				}
			}
		}

		out.println(cnt);
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

} public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int K = nextInt();
		int S = nextInt();

		int cnt = 0;
		for(int i=0;i<=K;i++) {
			for(int j=0;j<=K;j++) {
				int num = i+j;
				if(num + K >= S && num <= S) {
					cnt++;
				}else if(num > S) {
					break;
				}
			}
		}

		out.println(cnt);
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

} Main
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int K = nextInt();
		int S = nextInt();

		int cnt = 0;
		for(int i=0;i<=K;i++) {
			for(int j=0;j<=K;j++) {
				int num = i+j;
				if(num + K >= S && num <= S) {
					cnt++;
				}else if(num > S) {
					break;
				}
			}
		}

		out.println(cnt);
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

}