import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		int k,s,x,y,z,n;
		n = 0;
		Scanner sc = new Scanner(System.in);
		k = sc.nextInt();
		s = sc.nextInt();
		for(x = 0; x <= k; x++) {
			for(y = 0; y <= k; y++) {
				z = s - x - y;
				if(0 <= z && z <= k) {
					n++;
				}
			}
		}
		System.out.println(n);
		sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		int k,s,x,y,z,n;
		n = 0;
		Scanner sc = new Scanner(System.in);
		k = sc.nextInt();
		s = sc.nextInt();
		for(x = 0; x <= k; x++) {
			for(y = 0; y <= k; y++) {
				z = s - x - y;
				if(0 <= z && z <= k) {
					n++;
				}
			}
		}
		System.out.println(n);
		sc.close();
	}
} Main public static void main(String[] args) {
		int k,s,x,y,z,n;
		n = 0;
		Scanner sc = new Scanner(System.in);
		k = sc.nextInt();
		s = sc.nextInt();
		for(x = 0; x <= k; x++) {
			for(y = 0; y <= k; y++) {
				z = s - x - y;
				if(0 <= z && z <= k) {
					n++;
				}
			}
		}
		System.out.println(n);
		sc.close();
	} main {
		int k,s,x,y,z,n;
		n = 0;
		Scanner sc = new Scanner(System.in);
		k = sc.nextInt();
		s = sc.nextInt();
		for(x = 0; x <= k; x++) {
			for(y = 0; y <= k; y++) {
				z = s - x - y;
				if(0 <= z && z <= k) {
					n++;
				}
			}
		}
		System.out.println(n);
		sc.close();
	} int k k s s x x y y z z n; n n = 0 n 0 Scanner sc = new Scanner(System.in); sc new Scanner(System.in) k = sc.nextInt() k sc.nextInt() sc.nextInt sc s = sc.nextInt() s sc.nextInt() sc.nextInt sc for(x = 0; x <= k; x++) {
			for(y = 0; y <= k; y++) {
				z = s - x - y;
				if(0 <= z && z <= k) {
					n++;
				}
			}
		} x = 0; x = 0 x 0 x <= k x k x++ x++ x {
			for(y = 0; y <= k; y++) {
				z = s - x - y;
				if(0 <= z && z <= k) {
					n++;
				}
			}
		} {
			for(y = 0; y <= k; y++) {
				z = s - x - y;
				if(0 <= z && z <= k) {
					n++;
				}
			}
		} for(y = 0; y <= k; y++) {
				z = s - x - y;
				if(0 <= z && z <= k) {
					n++;
				}
			} y = 0; y = 0 y 0 y <= k y k y++ y++ y {
				z = s - x - y;
				if(0 <= z && z <= k) {
					n++;
				}
			} {
				z = s - x - y;
				if(0 <= z && z <= k) {
					n++;
				}
			} z = s - x - y z s - x - y s - x - y s x y if(0 <= z && z <= k) {
					n++;
				} 0 <= z && z <= k 0 <= z 0 z z <= k z k {
					n++;
				} n++ n System.out.println(n) System.out.println System.out System System.out n sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args) {
		int k,s,x,y,z,n;
		n = 0;
		Scanner sc = new Scanner(System.in);
		k = sc.nextInt();
		s = sc.nextInt();
		for(x = 0; x <= k; x++) {
			for(y = 0; y <= k; y++) {
				z = s - x - y;
				if(0 <= z && z <= k) {
					n++;
				}
			}
		}
		System.out.println(n);
		sc.close();
	}
} public class Main {
	public static void main(String[] args) {
		int k,s,x,y,z,n;
		n = 0;
		Scanner sc = new Scanner(System.in);
		k = sc.nextInt();
		s = sc.nextInt();
		for(x = 0; x <= k; x++) {
			for(y = 0; y <= k; y++) {
				z = s - x - y;
				if(0 <= z && z <= k) {
					n++;
				}
			}
		}
		System.out.println(n);
		sc.close();
	}
} Main
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		int k,s,x,y,z,n;
		n = 0;
		Scanner sc = new Scanner(System.in);
		k = sc.nextInt();
		s = sc.nextInt();
		for(x = 0; x <= k; x++) {
			for(y = 0; y <= k; y++) {
				z = s - x - y;
				if(0 <= z && z <= k) {
					n++;
				}
			}
		}
		System.out.println(n);
		sc.close();
	}
}