import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		sc.close();
		int cnt = 0;
		for(int x = 0; x <= K; x++) {
			for(int y = 0; y <= K; y++) {
				int t = S - x - y;
				if(t >= 0 && t <= K) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		sc.close();
		int cnt = 0;
		for(int x = 0; x <= K; x++) {
			for(int y = 0; y <= K; y++) {
				int t = S - x - y;
				if(t >= 0 && t <= K) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		sc.close();
		int cnt = 0;
		for(int x = 0; x <= K; x++) {
			for(int y = 0; y <= K; y++) {
				int t = S - x - y;
				if(t >= 0 && t <= K) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	} main {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		sc.close();
		int cnt = 0;
		for(int x = 0; x <= K; x++) {
			for(int y = 0; y <= K; y++) {
				int t = S - x - y;
				if(t >= 0 && t <= K) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	} 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 sc.close() sc.close sc int cnt = 0; cnt 0 for(int x = 0; x <= K; x++) {
			for(int y = 0; y <= K; y++) {
				int t = S - x - y;
				if(t >= 0 && t <= K) {
					cnt++;
				}
			}
		} int x = 0; int x = 0; x 0 x <= K x K x++ x++ x {
			for(int y = 0; y <= K; y++) {
				int t = S - x - y;
				if(t >= 0 && t <= K) {
					cnt++;
				}
			}
		} {
			for(int y = 0; y <= K; y++) {
				int t = S - x - y;
				if(t >= 0 && t <= K) {
					cnt++;
				}
			}
		} for(int y = 0; y <= K; y++) {
				int t = S - x - y;
				if(t >= 0 && t <= K) {
					cnt++;
				}
			} int y = 0; int y = 0; y 0 y <= K y K y++ y++ y {
				int t = S - x - y;
				if(t >= 0 && t <= K) {
					cnt++;
				}
			} {
				int t = S - x - y;
				if(t >= 0 && t <= K) {
					cnt++;
				}
			} int t = S - x - y; t S - x - y S - x - y S x y if(t >= 0 && t <= K) {
					cnt++;
				} t >= 0 && t <= K t >= 0 t 0 t <= K t K {
					cnt++;
				} cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		sc.close();
		int cnt = 0;
		for(int x = 0; x <= K; x++) {
			for(int y = 0; y <= K; y++) {
				int t = S - x - y;
				if(t >= 0 && t <= K) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		sc.close();
		int cnt = 0;
		for(int x = 0; x <= K; x++) {
			for(int y = 0; y <= K; y++) {
				int t = S - x - y;
				if(t >= 0 && t <= K) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
} Main
import java.util.Scanner;

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