import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	// Atcoder用のサンプルプログラム
	public static void main(String[] args) {
		String line = "";
		try {
			line = readLine();

			StringTokenizer st = new StringTokenizer(line, " ");
			String tempK = st.nextToken();
			String tempS = st.nextToken();

			int k = Integer.parseInt(tempK);
			int s = Integer.parseInt(tempS);
			int cnt = 0;
			// x y S-x-y
			for (int i = 0; i < s + 1; i++) {
				if (i > k) {
					continue;
				}
				for (int j = 0; j < s + 1; j++) {
					if (j > k) {
						continue;
					} else if (s - i - j > k) {
						continue;
					}

					if (i + j <= s) {
						//System.out.println(String.valueOf(i) + "," + String.valueOf(j) + "," + String.valueOf(s - i - j));
						cnt++;
					}
				}
			}
			System.out.println(cnt);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private static String readLine() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		return br.readLine();
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.StringTokenizer; StringTokenizer java.util public class Main {

	// Atcoder用のサンプルプログラム
	public static void main(String[] args) {
		String line = "";
		try {
			line = readLine();

			StringTokenizer st = new StringTokenizer(line, " ");
			String tempK = st.nextToken();
			String tempS = st.nextToken();

			int k = Integer.parseInt(tempK);
			int s = Integer.parseInt(tempS);
			int cnt = 0;
			// x y S-x-y
			for (int i = 0; i < s + 1; i++) {
				if (i > k) {
					continue;
				}
				for (int j = 0; j < s + 1; j++) {
					if (j > k) {
						continue;
					} else if (s - i - j > k) {
						continue;
					}

					if (i + j <= s) {
						//System.out.println(String.valueOf(i) + "," + String.valueOf(j) + "," + String.valueOf(s - i - j));
						cnt++;
					}
				}
			}
			System.out.println(cnt);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private static String readLine() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		return br.readLine();
	}

} Main // Atcoder用のサンプルプログラム
	public static void main(String[] args) {
		String line = "";
		try {
			line = readLine();

			StringTokenizer st = new StringTokenizer(line, " ");
			String tempK = st.nextToken();
			String tempS = st.nextToken();

			int k = Integer.parseInt(tempK);
			int s = Integer.parseInt(tempS);
			int cnt = 0;
			// x y S-x-y
			for (int i = 0; i < s + 1; i++) {
				if (i > k) {
					continue;
				}
				for (int j = 0; j < s + 1; j++) {
					if (j > k) {
						continue;
					} else if (s - i - j > k) {
						continue;
					}

					if (i + j <= s) {
						//System.out.println(String.valueOf(i) + "," + String.valueOf(j) + "," + String.valueOf(s - i - j));
						cnt++;
					}
				}
			}
			System.out.println(cnt);
		} catch (Exception e) {
			e.printStackTrace();
		}
	} main {
		String line = "";
		try {
			line = readLine();

			StringTokenizer st = new StringTokenizer(line, " ");
			String tempK = st.nextToken();
			String tempS = st.nextToken();

			int k = Integer.parseInt(tempK);
			int s = Integer.parseInt(tempS);
			int cnt = 0;
			// x y S-x-y
			for (int i = 0; i < s + 1; i++) {
				if (i > k) {
					continue;
				}
				for (int j = 0; j < s + 1; j++) {
					if (j > k) {
						continue;
					} else if (s - i - j > k) {
						continue;
					}

					if (i + j <= s) {
						//System.out.println(String.valueOf(i) + "," + String.valueOf(j) + "," + String.valueOf(s - i - j));
						cnt++;
					}
				}
			}
			System.out.println(cnt);
		} catch (Exception e) {
			e.printStackTrace();
		}
	} String line = ""; line "" try {
			line = readLine();

			StringTokenizer st = new StringTokenizer(line, " ");
			String tempK = st.nextToken();
			String tempS = st.nextToken();

			int k = Integer.parseInt(tempK);
			int s = Integer.parseInt(tempS);
			int cnt = 0;
			// x y S-x-y
			for (int i = 0; i < s + 1; i++) {
				if (i > k) {
					continue;
				}
				for (int j = 0; j < s + 1; j++) {
					if (j > k) {
						continue;
					} else if (s - i - j > k) {
						continue;
					}

					if (i + j <= s) {
						//System.out.println(String.valueOf(i) + "," + String.valueOf(j) + "," + String.valueOf(s - i - j));
						cnt++;
					}
				}
			}
			System.out.println(cnt);
		} catch (Exception e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		} Exception e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			line = readLine();

			StringTokenizer st = new StringTokenizer(line, " ");
			String tempK = st.nextToken();
			String tempS = st.nextToken();

			int k = Integer.parseInt(tempK);
			int s = Integer.parseInt(tempS);
			int cnt = 0;
			// x y S-x-y
			for (int i = 0; i < s + 1; i++) {
				if (i > k) {
					continue;
				}
				for (int j = 0; j < s + 1; j++) {
					if (j > k) {
						continue;
					} else if (s - i - j > k) {
						continue;
					}

					if (i + j <= s) {
						//System.out.println(String.valueOf(i) + "," + String.valueOf(j) + "," + String.valueOf(s - i - j));
						cnt++;
					}
				}
			}
			System.out.println(cnt);
		} line = readLine() line readLine() readLine StringTokenizer st = new StringTokenizer(line, " "); st new StringTokenizer(line, " ") String tempK = st.nextToken(); tempK st.nextToken() st.nextToken st String tempS = st.nextToken(); tempS st.nextToken() st.nextToken st int k = Integer.parseInt(tempK); k Integer.parseInt(tempK) Integer.parseInt Integer tempK int s = Integer.parseInt(tempS); s Integer.parseInt(tempS) Integer.parseInt Integer tempS int cnt = 0; cnt 0 for (int i = 0; i < s + 1; i++) {
				if (i > k) {
					continue;
				}
				for (int j = 0; j < s + 1; j++) {
					if (j > k) {
						continue;
					} else if (s - i - j > k) {
						continue;
					}

					if (i + j <= s) {
						//System.out.println(String.valueOf(i) + "," + String.valueOf(j) + "," + String.valueOf(s - i - j));
						cnt++;
					}
				}
			} int i = 0; int i = 0; i 0 i < s + 1 i s + 1 s 1 i++ i++ i {
				if (i > k) {
					continue;
				}
				for (int j = 0; j < s + 1; j++) {
					if (j > k) {
						continue;
					} else if (s - i - j > k) {
						continue;
					}

					if (i + j <= s) {
						//System.out.println(String.valueOf(i) + "," + String.valueOf(j) + "," + String.valueOf(s - i - j));
						cnt++;
					}
				}
			} {
				if (i > k) {
					continue;
				}
				for (int j = 0; j < s + 1; j++) {
					if (j > k) {
						continue;
					} else if (s - i - j > k) {
						continue;
					}

					if (i + j <= s) {
						//System.out.println(String.valueOf(i) + "," + String.valueOf(j) + "," + String.valueOf(s - i - j));
						cnt++;
					}
				}
			} if (i > k) {
					continue;
				} i > k i k {
					continue;
				} continue; for (int j = 0; j < s + 1; j++) {
					if (j > k) {
						continue;
					} else if (s - i - j > k) {
						continue;
					}

					if (i + j <= s) {
						//System.out.println(String.valueOf(i) + "," + String.valueOf(j) + "," + String.valueOf(s - i - j));
						cnt++;
					}
				} int j = 0; int j = 0; j 0 j < s + 1 j s + 1 s 1 j++ j++ j {
					if (j > k) {
						continue;
					} else if (s - i - j > k) {
						continue;
					}

					if (i + j <= s) {
						//System.out.println(String.valueOf(i) + "," + String.valueOf(j) + "," + String.valueOf(s - i - j));
						cnt++;
					}
				} {
					if (j > k) {
						continue;
					} else if (s - i - j > k) {
						continue;
					}

					if (i + j <= s) {
						//System.out.println(String.valueOf(i) + "," + String.valueOf(j) + "," + String.valueOf(s - i - j));
						cnt++;
					}
				} if (j > k) {
						continue;
					} else if (s - i - j > k) {
						continue;
					} j > k j k {
						continue;
					} continue; if (s - i - j > k) {
						continue;
					} s - i - j > k s - i - j s - i - j s i j k {
						continue;
					} continue; if (i + j <= s) {
						//System.out.println(String.valueOf(i) + "," + String.valueOf(j) + "," + String.valueOf(s - i - j));
						cnt++;
					} i + j <= s i + j i j s {
						//System.out.println(String.valueOf(i) + "," + String.valueOf(j) + "," + String.valueOf(s - i - j));
						cnt++;
					} cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args private static String readLine() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		return br.readLine();
	} readLine {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		return br.readLine();
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) return br.readLine(); br.readLine() br.readLine br public class Main {

	// Atcoder用のサンプルプログラム
	public static void main(String[] args) {
		String line = "";
		try {
			line = readLine();

			StringTokenizer st = new StringTokenizer(line, " ");
			String tempK = st.nextToken();
			String tempS = st.nextToken();

			int k = Integer.parseInt(tempK);
			int s = Integer.parseInt(tempS);
			int cnt = 0;
			// x y S-x-y
			for (int i = 0; i < s + 1; i++) {
				if (i > k) {
					continue;
				}
				for (int j = 0; j < s + 1; j++) {
					if (j > k) {
						continue;
					} else if (s - i - j > k) {
						continue;
					}

					if (i + j <= s) {
						//System.out.println(String.valueOf(i) + "," + String.valueOf(j) + "," + String.valueOf(s - i - j));
						cnt++;
					}
				}
			}
			System.out.println(cnt);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private static String readLine() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		return br.readLine();
	}

} public class Main {

	// Atcoder用のサンプルプログラム
	public static void main(String[] args) {
		String line = "";
		try {
			line = readLine();

			StringTokenizer st = new StringTokenizer(line, " ");
			String tempK = st.nextToken();
			String tempS = st.nextToken();

			int k = Integer.parseInt(tempK);
			int s = Integer.parseInt(tempS);
			int cnt = 0;
			// x y S-x-y
			for (int i = 0; i < s + 1; i++) {
				if (i > k) {
					continue;
				}
				for (int j = 0; j < s + 1; j++) {
					if (j > k) {
						continue;
					} else if (s - i - j > k) {
						continue;
					}

					if (i + j <= s) {
						//System.out.println(String.valueOf(i) + "," + String.valueOf(j) + "," + String.valueOf(s - i - j));
						cnt++;
					}
				}
			}
			System.out.println(cnt);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private static String readLine() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		return br.readLine();
	}

} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	// Atcoder用のサンプルプログラム
	public static void main(String[] args) {
		String line = "";
		try {
			line = readLine();

			StringTokenizer st = new StringTokenizer(line, " ");
			String tempK = st.nextToken();
			String tempS = st.nextToken();

			int k = Integer.parseInt(tempK);
			int s = Integer.parseInt(tempS);
			int cnt = 0;
			// x y S-x-y
			for (int i = 0; i < s + 1; i++) {
				if (i > k) {
					continue;
				}
				for (int j = 0; j < s + 1; j++) {
					if (j > k) {
						continue;
					} else if (s - i - j > k) {
						continue;
					}

					if (i + j <= s) {
						//System.out.println(String.valueOf(i) + "," + String.valueOf(j) + "," + String.valueOf(s - i - j));
						cnt++;
					}
				}
			}
			System.out.println(cnt);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private static String readLine() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		return br.readLine();
	}

}
