import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		int c = 0;
		for(int x = 0; x <= K; x++) {
			for(int y = 0 ; y <= K; y++) {
				int z = S - x - y;
				if(0 <= z && z <= K) {
					c += 1;
				}
			}
		}
		System.out.println(c);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		int c = 0;
		for(int x = 0; x <= K; x++) {
			for(int y = 0 ; y <= K; y++) {
				int z = S - x - y;
				if(0 <= z && z <= K) {
					c += 1;
				}
			}
		}
		System.out.println(c);
	}
} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		int c = 0;
		for(int x = 0; x <= K; x++) {
			for(int y = 0 ; y <= K; y++) {
				int z = S - x - y;
				if(0 <= z && z <= K) {
					c += 1;
				}
			}
		}
		System.out.println(c);
	} main {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		int c = 0;
		for(int x = 0; x <= K; x++) {
			for(int y = 0 ; y <= K; y++) {
				int z = S - x - y;
				if(0 <= z && z <= K) {
					c += 1;
				}
			}
		}
		System.out.println(c);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc int S = sc.nextInt(); S sc.nextInt() sc.nextInt sc int c = 0; c 0 for(int x = 0; x <= K; x++) {
			for(int y = 0 ; y <= K; y++) {
				int z = S - x - y;
				if(0 <= z && z <= K) {
					c += 1;
				}
			}
		} int x = 0; int x = 0; x 0 x <= K x K x++ x++ x {
			for(int y = 0 ; y <= K; y++) {
				int z = S - x - y;
				if(0 <= z && z <= K) {
					c += 1;
				}
			}
		} {
			for(int y = 0 ; y <= K; y++) {
				int z = S - x - y;
				if(0 <= z && z <= K) {
					c += 1;
				}
			}
		} for(int y = 0 ; y <= K; y++) {
				int z = S - x - y;
				if(0 <= z && z <= K) {
					c += 1;
				}
			} int y = 0 ; int y = 0 ; y 0 y <= K y K y++ y++ y {
				int z = S - x - y;
				if(0 <= z && z <= K) {
					c += 1;
				}
			} {
				int z = S - x - y;
				if(0 <= z && z <= K) {
					c += 1;
				}
			} int z = S - x - y; z S - x - y S - x - y S x y if(0 <= z && z <= K) {
					c += 1;
				} 0 <= z && z <= K 0 <= z 0 z z <= K z K {
					c += 1;
				} c += 1 c 1 System.out.println(c) System.out.println System.out System System.out c String[] args args public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		int c = 0;
		for(int x = 0; x <= K; x++) {
			for(int y = 0 ; y <= K; y++) {
				int z = S - x - y;
				if(0 <= z && z <= K) {
					c += 1;
				}
			}
		}
		System.out.println(c);
	}
} public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		int c = 0;
		for(int x = 0; x <= K; x++) {
			for(int y = 0 ; y <= K; y++) {
				int z = S - x - y;
				if(0 <= z && z <= K) {
					c += 1;
				}
			}
		}
		System.out.println(c);
	}
} Main
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		int c = 0;
		for(int x = 0; x <= K; x++) {
			for(int y = 0 ; y <= K; y++) {
				int z = S - x - y;
				if(0 <= z && z <= K) {
					c += 1;
				}
			}
		}
		System.out.println(c);
	}
}