import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// 標準入力
		Scanner sc = new Scanner(System.in);

		String line1 = sc.nextLine();

		List<String> lines1 = Arrays.asList(line1.split(" "));

		Integer K = Integer.parseInt(lines1.get(0));
		Integer S = Integer.parseInt(lines1.get(1));
/*
		Integer a = S / K;
		int res = 0;

		if (3 == a) {
			res = 1;
		} else if (2 <= a) {
			res = 9;
		} else if (1 < a) {
			res = (S-K) * 3;
		}else if (1 == a) {
			res = 3;
		}
*/

		int res = 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) {
					res++;
				}
			}
		}

		System.out.println(res);
	}

} import java.util.Arrays; Arrays java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		// 標準入力
		Scanner sc = new Scanner(System.in);

		String line1 = sc.nextLine();

		List<String> lines1 = Arrays.asList(line1.split(" "));

		Integer K = Integer.parseInt(lines1.get(0));
		Integer S = Integer.parseInt(lines1.get(1));
/*
		Integer a = S / K;
		int res = 0;

		if (3 == a) {
			res = 1;
		} else if (2 <= a) {
			res = 9;
		} else if (1 < a) {
			res = (S-K) * 3;
		}else if (1 == a) {
			res = 3;
		}
*/

		int res = 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) {
					res++;
				}
			}
		}

		System.out.println(res);
	}

} Main public static void main(String[] args) {
		// 標準入力
		Scanner sc = new Scanner(System.in);

		String line1 = sc.nextLine();

		List<String> lines1 = Arrays.asList(line1.split(" "));

		Integer K = Integer.parseInt(lines1.get(0));
		Integer S = Integer.parseInt(lines1.get(1));
/*
		Integer a = S / K;
		int res = 0;

		if (3 == a) {
			res = 1;
		} else if (2 <= a) {
			res = 9;
		} else if (1 < a) {
			res = (S-K) * 3;
		}else if (1 == a) {
			res = 3;
		}
*/

		int res = 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) {
					res++;
				}
			}
		}

		System.out.println(res);
	} main {
		// 標準入力
		Scanner sc = new Scanner(System.in);

		String line1 = sc.nextLine();

		List<String> lines1 = Arrays.asList(line1.split(" "));

		Integer K = Integer.parseInt(lines1.get(0));
		Integer S = Integer.parseInt(lines1.get(1));
/*
		Integer a = S / K;
		int res = 0;

		if (3 == a) {
			res = 1;
		} else if (2 <= a) {
			res = 9;
		} else if (1 < a) {
			res = (S-K) * 3;
		}else if (1 == a) {
			res = 3;
		}
*/

		int res = 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) {
					res++;
				}
			}
		}

		System.out.println(res);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String line1 = sc.nextLine(); line1 sc.nextLine() sc.nextLine sc List<String> lines1 = Arrays.asList(line1.split(" ")); lines1 Arrays.asList(line1.split(" ")) Arrays.asList Arrays line1.split(" ") line1.split line1 " " Integer K = Integer.parseInt(lines1.get(0)); K Integer.parseInt(lines1.get(0)) Integer.parseInt Integer lines1.get(0) lines1.get lines1 0 Integer S = Integer.parseInt(lines1.get(1)); S Integer.parseInt(lines1.get(1)) Integer.parseInt Integer lines1.get(1) lines1.get lines1 1 int res = 0; res 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) {
					res++;
				}
			}
		} 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) {
					res++;
				}
			}
		} {
			for(int y = 0; y <= K; y++) {
				int z = S-x-y;
				if(0 <= z && z <= K) {
					res++;
				}
			}
		} for(int y = 0; y <= K; y++) {
				int z = S-x-y;
				if(0 <= z && z <= K) {
					res++;
				}
			} 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) {
					res++;
				}
			} {
				int z = S-x-y;
				if(0 <= z && z <= K) {
					res++;
				}
			} int z = S-x-y; z S-x-y S-x-y S x y if(0 <= z && z <= K) {
					res++;
				} 0 <= z && z <= K 0 <= z 0 z z <= K z K {
					res++;
				} res++ res System.out.println(res) System.out.println System.out System System.out res String[] args args public class Main {
	public static void main(String[] args) {
		// 標準入力
		Scanner sc = new Scanner(System.in);

		String line1 = sc.nextLine();

		List<String> lines1 = Arrays.asList(line1.split(" "));

		Integer K = Integer.parseInt(lines1.get(0));
		Integer S = Integer.parseInt(lines1.get(1));
/*
		Integer a = S / K;
		int res = 0;

		if (3 == a) {
			res = 1;
		} else if (2 <= a) {
			res = 9;
		} else if (1 < a) {
			res = (S-K) * 3;
		}else if (1 == a) {
			res = 3;
		}
*/

		int res = 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) {
					res++;
				}
			}
		}

		System.out.println(res);
	}

} public class Main {
	public static void main(String[] args) {
		// 標準入力
		Scanner sc = new Scanner(System.in);

		String line1 = sc.nextLine();

		List<String> lines1 = Arrays.asList(line1.split(" "));

		Integer K = Integer.parseInt(lines1.get(0));
		Integer S = Integer.parseInt(lines1.get(1));
/*
		Integer a = S / K;
		int res = 0;

		if (3 == a) {
			res = 1;
		} else if (2 <= a) {
			res = 9;
		} else if (1 < a) {
			res = (S-K) * 3;
		}else if (1 == a) {
			res = 3;
		}
*/

		int res = 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) {
					res++;
				}
			}
		}

		System.out.println(res);
	}

} Main
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// 標準入力
		Scanner sc = new Scanner(System.in);

		String line1 = sc.nextLine();

		List<String> lines1 = Arrays.asList(line1.split(" "));

		Integer K = Integer.parseInt(lines1.get(0));
		Integer S = Integer.parseInt(lines1.get(1));
/*
		Integer a = S / K;
		int res = 0;

		if (3 == a) {
			res = 1;
		} else if (2 <= a) {
			res = 9;
		} else if (1 < a) {
			res = (S-K) * 3;
		}else if (1 == a) {
			res = 3;
		}
*/

		int res = 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) {
					res++;
				}
			}
		}

		System.out.println(res);
	}

}