import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int want = sc.nextInt();
		int count = 0;
		for(int i = 0; i <= k; i++) {
			for(int m = 0; m <= k; m++) {
				if(want - i - m <= k && want - i - m >= 0) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int want = sc.nextInt();
		int count = 0;
		for(int i = 0; i <= k; i++) {
			for(int m = 0; m <= k; m++) {
				if(want - i - m <= k && want - i - m >= 0) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
} Main public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int want = sc.nextInt();
		int count = 0;
		for(int i = 0; i <= k; i++) {
			for(int m = 0; m <= k; m++) {
				if(want - i - m <= k && want - i - m >= 0) {
					count++;
				}
			}
		}
		System.out.println(count);
	} main {
		final Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int want = sc.nextInt();
		int count = 0;
		for(int i = 0; i <= k; i++) {
			for(int m = 0; m <= k; m++) {
				if(want - i - m <= k && want - i - m >= 0) {
					count++;
				}
			}
		}
		System.out.println(count);
	} final Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc int want = sc.nextInt(); want sc.nextInt() sc.nextInt sc int count = 0; count 0 for(int i = 0; i <= k; i++) {
			for(int m = 0; m <= k; m++) {
				if(want - i - m <= k && want - i - m >= 0) {
					count++;
				}
			}
		} int i = 0; int i = 0; i 0 i <= k i k i++ i++ i {
			for(int m = 0; m <= k; m++) {
				if(want - i - m <= k && want - i - m >= 0) {
					count++;
				}
			}
		} {
			for(int m = 0; m <= k; m++) {
				if(want - i - m <= k && want - i - m >= 0) {
					count++;
				}
			}
		} for(int m = 0; m <= k; m++) {
				if(want - i - m <= k && want - i - m >= 0) {
					count++;
				}
			} int m = 0; int m = 0; m 0 m <= k m k m++ m++ m {
				if(want - i - m <= k && want - i - m >= 0) {
					count++;
				}
			} {
				if(want - i - m <= k && want - i - m >= 0) {
					count++;
				}
			} if(want - i - m <= k && want - i - m >= 0) {
					count++;
				} want - i - m <= k && want - i - m >= 0 want - i - m <= k want - i - m want - i - m want i m k want - i - m >= 0 want - i - m want - i - m want i m 0 {
					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) {
		final Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int want = sc.nextInt();
		int count = 0;
		for(int i = 0; i <= k; i++) {
			for(int m = 0; m <= k; m++) {
				if(want - i - m <= k && want - i - m >= 0) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
} public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int want = sc.nextInt();
		int count = 0;
		for(int i = 0; i <= k; i++) {
			for(int m = 0; m <= k; m++) {
				if(want - i - m <= k && want - i - m >= 0) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int want = sc.nextInt();
		int count = 0;
		for(int i = 0; i <= k; i++) {
			for(int m = 0; m <= k; m++) {
				if(want - i - m <= k && want - i - m >= 0) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
}