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

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Iterator<String> sc) {
		int K = Integer.parseInt(sc.next());
		int S = Integer.parseInt(sc.next());
		int sum = 0;
		for (int x = 0; x <= K && x <= S; x++) {
			int remaining = S - x;
			sum += Math.max(Math.min(remaining, K) - Math.max(remaining - K, 0) + 1, 0);
		}
		System.out.println(sum);
	}
}

class Main {
	public static void main(String... args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Iterator<String>() {
			private StringTokenizer tokenizer;

			public boolean hasNext() {
				return true;
			}

			public String next() {
				if (tokenizer == null || !tokenizer.hasMoreTokens()) {
					try {
						tokenizer = new StringTokenizer(reader.readLine());
					} catch (IOException e) {
						throw new UncheckedIOException(e);
					}
				}
				return tokenizer.nextToken();
			}
		});
	}
} Iterator<String>() {
			private StringTokenizer tokenizer;

			public boolean hasNext() {
				return true;
			}

			public String next() {
				if (tokenizer == null || !tokenizer.hasMoreTokens()) {
					try {
						tokenizer = new StringTokenizer(reader.readLine());
					} catch (IOException e) {
						throw new UncheckedIOException(e);
					}
				}
				return tokenizer.nextToken();
			}
		} private StringTokenizer tokenizer; tokenizer public boolean hasNext() {
				return true;
			} hasNext {
				return true;
			} return true; true public String next() {
				if (tokenizer == null || !tokenizer.hasMoreTokens()) {
					try {
						tokenizer = new StringTokenizer(reader.readLine());
					} catch (IOException e) {
						throw new UncheckedIOException(e);
					}
				}
				return tokenizer.nextToken();
			} next {
				if (tokenizer == null || !tokenizer.hasMoreTokens()) {
					try {
						tokenizer = new StringTokenizer(reader.readLine());
					} catch (IOException e) {
						throw new UncheckedIOException(e);
					}
				}
				return tokenizer.nextToken();
			} if (tokenizer == null || !tokenizer.hasMoreTokens()) {
					try {
						tokenizer = new StringTokenizer(reader.readLine());
					} catch (IOException e) {
						throw new UncheckedIOException(e);
					}
				} tokenizer == null || !tokenizer.hasMoreTokens() tokenizer == null tokenizer null !tokenizer.hasMoreTokens() tokenizer.hasMoreTokens() tokenizer.hasMoreTokens tokenizer {
					try {
						tokenizer = new StringTokenizer(reader.readLine());
					} catch (IOException e) {
						throw new UncheckedIOException(e);
					}
				} try {
						tokenizer = new StringTokenizer(reader.readLine());
					} catch (IOException e) {
						throw new UncheckedIOException(e);
					} catch (IOException e) {
						throw new UncheckedIOException(e);
					} IOException e {
						throw new UncheckedIOException(e);
					} throw new UncheckedIOException(e); new UncheckedIOException(e) {
						tokenizer = new StringTokenizer(reader.readLine());
					} tokenizer = new StringTokenizer(reader.readLine()) tokenizer new StringTokenizer(reader.readLine()) return tokenizer.nextToken(); tokenizer.nextToken() tokenizer.nextToken tokenizer import java.io.*; io.* java import java.util.*; util.* java final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Iterator<String> sc) {
		int K = Integer.parseInt(sc.next());
		int S = Integer.parseInt(sc.next());
		int sum = 0;
		for (int x = 0; x <= K && x <= S; x++) {
			int remaining = S - x;
			sum += Math.max(Math.min(remaining, K) - Math.max(remaining - K, 0) + 1, 0);
		}
		System.out.println(sum);
	}
} Solver static final Solver INSTANCE = new Solver(); INSTANCE new Solver() void solve(Iterator<String> sc) {
		int K = Integer.parseInt(sc.next());
		int S = Integer.parseInt(sc.next());
		int sum = 0;
		for (int x = 0; x <= K && x <= S; x++) {
			int remaining = S - x;
			sum += Math.max(Math.min(remaining, K) - Math.max(remaining - K, 0) + 1, 0);
		}
		System.out.println(sum);
	} solve {
		int K = Integer.parseInt(sc.next());
		int S = Integer.parseInt(sc.next());
		int sum = 0;
		for (int x = 0; x <= K && x <= S; x++) {
			int remaining = S - x;
			sum += Math.max(Math.min(remaining, K) - Math.max(remaining - K, 0) + 1, 0);
		}
		System.out.println(sum);
	} 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 sum = 0; sum 0 for (int x = 0; x <= K && x <= S; x++) {
			int remaining = S - x;
			sum += Math.max(Math.min(remaining, K) - Math.max(remaining - K, 0) + 1, 0);
		} int x = 0; int x = 0; x 0 x <= K && x <= S x <= K x K x <= S x S x++ x++ x {
			int remaining = S - x;
			sum += Math.max(Math.min(remaining, K) - Math.max(remaining - K, 0) + 1, 0);
		} {
			int remaining = S - x;
			sum += Math.max(Math.min(remaining, K) - Math.max(remaining - K, 0) + 1, 0);
		} int remaining = S - x; remaining S - x S x sum += Math.max(Math.min(remaining, K) - Math.max(remaining - K, 0) + 1, 0) sum Math.max(Math.min(remaining, K) - Math.max(remaining - K, 0) + 1, 0) Math.max Math Math.min(remaining, K) - Math.max(remaining - K, 0) + 1 Math.min(remaining, K) - Math.max(remaining - K, 0) Math.min(remaining, K) Math.min Math remaining K Math.max(remaining - K, 0) Math.max Math remaining - K remaining K 0 1 0 System.out.println(sum) System.out.println System.out System System.out sum Iterator<String> sc sc class Main {
	public static void main(String... args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Iterator<String>() {
			private StringTokenizer tokenizer;

			public boolean hasNext() {
				return true;
			}

			public String next() {
				if (tokenizer == null || !tokenizer.hasMoreTokens()) {
					try {
						tokenizer = new StringTokenizer(reader.readLine());
					} catch (IOException e) {
						throw new UncheckedIOException(e);
					}
				}
				return tokenizer.nextToken();
			}
		});
	}
} Main public static void main(String... args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Iterator<String>() {
			private StringTokenizer tokenizer;

			public boolean hasNext() {
				return true;
			}

			public String next() {
				if (tokenizer == null || !tokenizer.hasMoreTokens()) {
					try {
						tokenizer = new StringTokenizer(reader.readLine());
					} catch (IOException e) {
						throw new UncheckedIOException(e);
					}
				}
				return tokenizer.nextToken();
			}
		});
	} main {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Iterator<String>() {
			private StringTokenizer tokenizer;

			public boolean hasNext() {
				return true;
			}

			public String next() {
				if (tokenizer == null || !tokenizer.hasMoreTokens()) {
					try {
						tokenizer = new StringTokenizer(reader.readLine());
					} catch (IOException e) {
						throw new UncheckedIOException(e);
					}
				}
				return tokenizer.nextToken();
			}
		});
	} BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); reader new BufferedReader(new InputStreamReader(System.in)) Solver.INSTANCE.solve(new Iterator<String>() {
			private StringTokenizer tokenizer;

			public boolean hasNext() {
				return true;
			}

			public String next() {
				if (tokenizer == null || !tokenizer.hasMoreTokens()) {
					try {
						tokenizer = new StringTokenizer(reader.readLine());
					} catch (IOException e) {
						throw new UncheckedIOException(e);
					}
				}
				return tokenizer.nextToken();
			}
		}) Solver.INSTANCE.solve Solver.INSTANCE Solver Solver.INSTANCE new Iterator<String>() {
			private StringTokenizer tokenizer;

			public boolean hasNext() {
				return true;
			}

			public String next() {
				if (tokenizer == null || !tokenizer.hasMoreTokens()) {
					try {
						tokenizer = new StringTokenizer(reader.readLine());
					} catch (IOException e) {
						throw new UncheckedIOException(e);
					}
				}
				return tokenizer.nextToken();
			}
		} String... args args
import java.io.*;
import java.util.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Iterator<String> sc) {
		int K = Integer.parseInt(sc.next());
		int S = Integer.parseInt(sc.next());
		int sum = 0;
		for (int x = 0; x <= K && x <= S; x++) {
			int remaining = S - x;
			sum += Math.max(Math.min(remaining, K) - Math.max(remaining - K, 0) + 1, 0);
		}
		System.out.println(sum);
	}
}

class Main {
	public static void main(String... args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Iterator<String>() {
			private StringTokenizer tokenizer;

			public boolean hasNext() {
				return true;
			}

			public String next() {
				if (tokenizer == null || !tokenizer.hasMoreTokens()) {
					try {
						tokenizer = new StringTokenizer(reader.readLine());
					} catch (IOException e) {
						throw new UncheckedIOException(e);
					}
				}
				return tokenizer.nextToken();
			}
		});
	}
}