
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line[] = br.readLine().split(" ");
		int k = Integer.parseInt(line[0]);
		int s = Integer.parseInt(line[1]);
		int count = 0;

		for (int i = 0; i <= k; i++) {
			for (int j = 0; j <= k; j++) {
				if (0 <= s - i - j && s - i - j <= k) {
					count++;
				}
			}
		}

		System.out.println(count);
	}

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

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line[] = br.readLine().split(" ");
		int k = Integer.parseInt(line[0]);
		int s = Integer.parseInt(line[1]);
		int count = 0;

		for (int i = 0; i <= k; i++) {
			for (int j = 0; j <= k; j++) {
				if (0 <= s - i - j && s - i - j <= k) {
					count++;
				}
			}
		}

		System.out.println(count);
	}

} Main public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line[] = br.readLine().split(" ");
		int k = Integer.parseInt(line[0]);
		int s = Integer.parseInt(line[1]);
		int count = 0;

		for (int i = 0; i <= k; i++) {
			for (int j = 0; j <= k; j++) {
				if (0 <= s - i - j && s - i - j <= k) {
					count++;
				}
			}
		}

		System.out.println(count);
	} main {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line[] = br.readLine().split(" ");
		int k = Integer.parseInt(line[0]);
		int s = Integer.parseInt(line[1]);
		int count = 0;

		for (int i = 0; i <= k; i++) {
			for (int j = 0; j <= k; j++) {
				if (0 <= s - i - j && s - i - j <= k) {
					count++;
				}
			}
		}

		System.out.println(count);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String line[] = br.readLine().split(" "); line br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int k = Integer.parseInt(line[0]); k Integer.parseInt(line[0]) Integer.parseInt Integer line[0] line 0 int s = Integer.parseInt(line[1]); s Integer.parseInt(line[1]) Integer.parseInt Integer line[1] line 1 int count = 0; count 0 for (int i = 0; i <= k; i++) {
			for (int j = 0; j <= k; j++) {
				if (0 <= s - i - j && s - i - j <= k) {
					count++;
				}
			}
		} int i = 0; int i = 0; i 0 i <= k i k i++ i++ i {
			for (int j = 0; j <= k; j++) {
				if (0 <= s - i - j && s - i - j <= k) {
					count++;
				}
			}
		} {
			for (int j = 0; j <= k; j++) {
				if (0 <= s - i - j && s - i - j <= k) {
					count++;
				}
			}
		} for (int j = 0; j <= k; j++) {
				if (0 <= s - i - j && s - i - j <= k) {
					count++;
				}
			} int j = 0; int j = 0; j 0 j <= k j k j++ j++ j {
				if (0 <= s - i - j && s - i - j <= k) {
					count++;
				}
			} {
				if (0 <= s - i - j && s - i - j <= k) {
					count++;
				}
			} if (0 <= s - i - j && s - i - j <= k) {
					count++;
				} 0 <= s - i - j && s - i - j <= k 0 <= s - i - j 0 s - i - j s - i - j s i j s - i - j <= k s - i - j s - i - j s i j k {
					count++;
				} count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line[] = br.readLine().split(" ");
		int k = Integer.parseInt(line[0]);
		int s = Integer.parseInt(line[1]);
		int count = 0;

		for (int i = 0; i <= k; i++) {
			for (int j = 0; j <= k; j++) {
				if (0 <= s - i - j && s - i - j <= k) {
					count++;
				}
			}
		}

		System.out.println(count);
	}

} public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line[] = br.readLine().split(" ");
		int k = Integer.parseInt(line[0]);
		int s = Integer.parseInt(line[1]);
		int count = 0;

		for (int i = 0; i <= k; i++) {
			for (int j = 0; j <= k; j++) {
				if (0 <= s - i - j && s - i - j <= k) {
					count++;
				}
			}
		}

		System.out.println(count);
	}

} Main

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line[] = br.readLine().split(" ");
		int k = Integer.parseInt(line[0]);
		int s = Integer.parseInt(line[1]);
		int count = 0;

		for (int i = 0; i <= k; i++) {
			for (int j = 0; j <= k; j++) {
				if (0 <= s - i - j && s - i - j <= k) {
					count++;
				}
			}
		}

		System.out.println(count);
	}

}
