import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		SumOfThreeIntegers solver = new SumOfThreeIntegers();
		solver.readInput();
		solver.solve();
		solver.writeOutput();
	}

	static class SumOfThreeIntegers {
		private int k;
		private int s;
		private Scanner scanner;
		private int output;

		public SumOfThreeIntegers() {
			scanner = new Scanner(System.in);
			output = 0;
		}

		public void readInput() {
			k = scanner.nextInt();
			s = scanner.nextInt();
		}

		public void solve() {
			for(int x=0; x<=k;x++) {
				for(int y=0; y<=k;y++) {
					if(s-x-y <= k && s-x-y>=0) {
						output++;
					}
				}
			}

		}

		public void writeOutput() {
			System.out.print(output);
		}

	}

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

	public static void main(String[] args) {
		SumOfThreeIntegers solver = new SumOfThreeIntegers();
		solver.readInput();
		solver.solve();
		solver.writeOutput();
	}

	static class SumOfThreeIntegers {
		private int k;
		private int s;
		private Scanner scanner;
		private int output;

		public SumOfThreeIntegers() {
			scanner = new Scanner(System.in);
			output = 0;
		}

		public void readInput() {
			k = scanner.nextInt();
			s = scanner.nextInt();
		}

		public void solve() {
			for(int x=0; x<=k;x++) {
				for(int y=0; y<=k;y++) {
					if(s-x-y <= k && s-x-y>=0) {
						output++;
					}
				}
			}

		}

		public void writeOutput() {
			System.out.print(output);
		}

	}

} Main public static void main(String[] args) {
		SumOfThreeIntegers solver = new SumOfThreeIntegers();
		solver.readInput();
		solver.solve();
		solver.writeOutput();
	} main {
		SumOfThreeIntegers solver = new SumOfThreeIntegers();
		solver.readInput();
		solver.solve();
		solver.writeOutput();
	} SumOfThreeIntegers solver = new SumOfThreeIntegers(); solver new SumOfThreeIntegers() solver.readInput() solver.readInput solver solver.solve() solver.solve solver solver.writeOutput() solver.writeOutput solver String[] args args static class SumOfThreeIntegers {
		private int k;
		private int s;
		private Scanner scanner;
		private int output;

		public SumOfThreeIntegers() {
			scanner = new Scanner(System.in);
			output = 0;
		}

		public void readInput() {
			k = scanner.nextInt();
			s = scanner.nextInt();
		}

		public void solve() {
			for(int x=0; x<=k;x++) {
				for(int y=0; y<=k;y++) {
					if(s-x-y <= k && s-x-y>=0) {
						output++;
					}
				}
			}

		}

		public void writeOutput() {
			System.out.print(output);
		}

	} SumOfThreeIntegers private int k; k private int s; s private Scanner scanner; scanner private int output; output public SumOfThreeIntegers() {
			scanner = new Scanner(System.in);
			output = 0;
		} SumOfThreeIntegers {
			scanner = new Scanner(System.in);
			output = 0;
		} scanner = new Scanner(System.in) scanner new Scanner(System.in) output = 0 output 0 public void readInput() {
			k = scanner.nextInt();
			s = scanner.nextInt();
		} readInput {
			k = scanner.nextInt();
			s = scanner.nextInt();
		} k = scanner.nextInt() k scanner.nextInt() scanner.nextInt scanner s = scanner.nextInt() s scanner.nextInt() scanner.nextInt scanner public void solve() {
			for(int x=0; x<=k;x++) {
				for(int y=0; y<=k;y++) {
					if(s-x-y <= k && s-x-y>=0) {
						output++;
					}
				}
			}

		} solve {
			for(int x=0; x<=k;x++) {
				for(int y=0; y<=k;y++) {
					if(s-x-y <= k && s-x-y>=0) {
						output++;
					}
				}
			}

		} for(int x=0; x<=k;x++) {
				for(int y=0; y<=k;y++) {
					if(s-x-y <= k && s-x-y>=0) {
						output++;
					}
				}
			} int x=0; int x=0; x 0 x<=k x k x++ x++ x {
				for(int y=0; y<=k;y++) {
					if(s-x-y <= k && s-x-y>=0) {
						output++;
					}
				}
			} {
				for(int y=0; y<=k;y++) {
					if(s-x-y <= k && s-x-y>=0) {
						output++;
					}
				}
			} for(int y=0; y<=k;y++) {
					if(s-x-y <= k && s-x-y>=0) {
						output++;
					}
				} int y=0; int y=0; y 0 y<=k y k y++ y++ y {
					if(s-x-y <= k && s-x-y>=0) {
						output++;
					}
				} {
					if(s-x-y <= k && s-x-y>=0) {
						output++;
					}
				} if(s-x-y <= k && s-x-y>=0) {
						output++;
					} s-x-y <= k && s-x-y>=0 s-x-y <= k s-x-y s-x-y s x y k s-x-y>=0 s-x-y s-x-y s x y 0 {
						output++;
					} output++ output public void writeOutput() {
			System.out.print(output);
		} writeOutput {
			System.out.print(output);
		} System.out.print(output) System.out.print System.out System System.out output public class Main {

	public static void main(String[] args) {
		SumOfThreeIntegers solver = new SumOfThreeIntegers();
		solver.readInput();
		solver.solve();
		solver.writeOutput();
	}

	static class SumOfThreeIntegers {
		private int k;
		private int s;
		private Scanner scanner;
		private int output;

		public SumOfThreeIntegers() {
			scanner = new Scanner(System.in);
			output = 0;
		}

		public void readInput() {
			k = scanner.nextInt();
			s = scanner.nextInt();
		}

		public void solve() {
			for(int x=0; x<=k;x++) {
				for(int y=0; y<=k;y++) {
					if(s-x-y <= k && s-x-y>=0) {
						output++;
					}
				}
			}

		}

		public void writeOutput() {
			System.out.print(output);
		}

	}

} public class Main {

	public static void main(String[] args) {
		SumOfThreeIntegers solver = new SumOfThreeIntegers();
		solver.readInput();
		solver.solve();
		solver.writeOutput();
	}

	static class SumOfThreeIntegers {
		private int k;
		private int s;
		private Scanner scanner;
		private int output;

		public SumOfThreeIntegers() {
			scanner = new Scanner(System.in);
			output = 0;
		}

		public void readInput() {
			k = scanner.nextInt();
			s = scanner.nextInt();
		}

		public void solve() {
			for(int x=0; x<=k;x++) {
				for(int y=0; y<=k;y++) {
					if(s-x-y <= k && s-x-y>=0) {
						output++;
					}
				}
			}

		}

		public void writeOutput() {
			System.out.print(output);
		}

	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		SumOfThreeIntegers solver = new SumOfThreeIntegers();
		solver.readInput();
		solver.solve();
		solver.writeOutput();
	}

	static class SumOfThreeIntegers {
		private int k;
		private int s;
		private Scanner scanner;
		private int output;

		public SumOfThreeIntegers() {
			scanner = new Scanner(System.in);
			output = 0;
		}

		public void readInput() {
			k = scanner.nextInt();
			s = scanner.nextInt();
		}

		public void solve() {
			for(int x=0; x<=k;x++) {
				for(int y=0; y<=k;y++) {
					if(s-x-y <= k && s-x-y>=0) {
						output++;
					}
				}
			}

		}

		public void writeOutput() {
			System.out.print(output);
		}

	}

}
