import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int K = scan.nextInt();
		int S = scan.nextInt();
		int ans = 0;
		int z = 0;
		for(int x = 0; x <= K; x++) {
			for(int y = 0; y <= K; y++) {
				z = S - x - y;
				if(0 <= z && z <= K) {
					ans++;
				}
			}
		}
		System.out.println(ans);
		scan.close();
	}

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

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int K = scan.nextInt();
		int S = scan.nextInt();
		int ans = 0;
		int z = 0;
		for(int x = 0; x <= K; x++) {
			for(int y = 0; y <= K; y++) {
				z = S - x - y;
				if(0 <= z && z <= K) {
					ans++;
				}
			}
		}
		System.out.println(ans);
		scan.close();
	}

} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int K = scan.nextInt();
		int S = scan.nextInt();
		int ans = 0;
		int z = 0;
		for(int x = 0; x <= K; x++) {
			for(int y = 0; y <= K; y++) {
				z = S - x - y;
				if(0 <= z && z <= K) {
					ans++;
				}
			}
		}
		System.out.println(ans);
		scan.close();
	} main {
		Scanner scan = new Scanner(System.in);
		int K = scan.nextInt();
		int S = scan.nextInt();
		int ans = 0;
		int z = 0;
		for(int x = 0; x <= K; x++) {
			for(int y = 0; y <= K; y++) {
				z = S - x - y;
				if(0 <= z && z <= K) {
					ans++;
				}
			}
		}
		System.out.println(ans);
		scan.close();
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int K = scan.nextInt(); K scan.nextInt() scan.nextInt scan int S = scan.nextInt(); S scan.nextInt() scan.nextInt scan int ans = 0; ans 0 int z = 0; z 0 for(int x = 0; x <= K; x++) {
			for(int y = 0; y <= K; y++) {
				z = S - x - y;
				if(0 <= z && z <= K) {
					ans++;
				}
			}
		} int x = 0; int x = 0; x 0 x <= K x K x++ x++ x {
			for(int y = 0; y <= K; y++) {
				z = S - x - y;
				if(0 <= z && z <= K) {
					ans++;
				}
			}
		} {
			for(int y = 0; y <= K; y++) {
				z = S - x - y;
				if(0 <= z && z <= K) {
					ans++;
				}
			}
		} for(int y = 0; y <= K; y++) {
				z = S - x - y;
				if(0 <= z && z <= K) {
					ans++;
				}
			} int y = 0; int y = 0; y 0 y <= K y K y++ y++ y {
				z = S - x - y;
				if(0 <= z && z <= K) {
					ans++;
				}
			} {
				z = S - x - y;
				if(0 <= z && z <= K) {
					ans++;
				}
			} z = S - x - y z S - x - y S - x - y S x y if(0 <= z && z <= K) {
					ans++;
				} 0 <= z && z <= K 0 <= z 0 z z <= K z K {
					ans++;
				} ans++ ans System.out.println(ans) System.out.println System.out System System.out ans scan.close() scan.close scan String[] args args public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int K = scan.nextInt();
		int S = scan.nextInt();
		int ans = 0;
		int z = 0;
		for(int x = 0; x <= K; x++) {
			for(int y = 0; y <= K; y++) {
				z = S - x - y;
				if(0 <= z && z <= K) {
					ans++;
				}
			}
		}
		System.out.println(ans);
		scan.close();
	}

} public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int K = scan.nextInt();
		int S = scan.nextInt();
		int ans = 0;
		int z = 0;
		for(int x = 0; x <= K; x++) {
			for(int y = 0; y <= K; y++) {
				z = S - x - y;
				if(0 <= z && z <= K) {
					ans++;
				}
			}
		}
		System.out.println(ans);
		scan.close();
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int K = scan.nextInt();
		int S = scan.nextInt();
		int ans = 0;
		int z = 0;
		for(int x = 0; x <= K; x++) {
			for(int y = 0; y <= K; y++) {
				z = S - x - y;
				if(0 <= z && z <= K) {
					ans++;
				}
			}
		}
		System.out.println(ans);
		scan.close();
	}

}
