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();
		int answer = 0;
		for(int x = 0;x <= k;x++) {
			if(x > s) {
				break;
			}
			for(int y = 0;y <= k;y++) {
				if(x + y > s) {
					break;
				}else {
					if(x + y + k >= s) {
						answer++;
					}
				}
			}
		}
		System.out.println(answer);
	}
} 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();
		int answer = 0;
		for(int x = 0;x <= k;x++) {
			if(x > s) {
				break;
			}
			for(int y = 0;y <= k;y++) {
				if(x + y > s) {
					break;
				}else {
					if(x + y + k >= s) {
						answer++;
					}
				}
			}
		}
		System.out.println(answer);
	}
} Main public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int answer = 0;
		for(int x = 0;x <= k;x++) {
			if(x > s) {
				break;
			}
			for(int y = 0;y <= k;y++) {
				if(x + y > s) {
					break;
				}else {
					if(x + y + k >= s) {
						answer++;
					}
				}
			}
		}
		System.out.println(answer);
	} main {


		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int answer = 0;
		for(int x = 0;x <= k;x++) {
			if(x > s) {
				break;
			}
			for(int y = 0;y <= k;y++) {
				if(x + y > s) {
					break;
				}else {
					if(x + y + k >= s) {
						answer++;
					}
				}
			}
		}
		System.out.println(answer);
	} 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 answer = 0; answer 0 for(int x = 0;x <= k;x++) {
			if(x > s) {
				break;
			}
			for(int y = 0;y <= k;y++) {
				if(x + y > s) {
					break;
				}else {
					if(x + y + k >= s) {
						answer++;
					}
				}
			}
		} int x = 0; int x = 0; x 0 x <= k x k x++ x++ x {
			if(x > s) {
				break;
			}
			for(int y = 0;y <= k;y++) {
				if(x + y > s) {
					break;
				}else {
					if(x + y + k >= s) {
						answer++;
					}
				}
			}
		} {
			if(x > s) {
				break;
			}
			for(int y = 0;y <= k;y++) {
				if(x + y > s) {
					break;
				}else {
					if(x + y + k >= s) {
						answer++;
					}
				}
			}
		} if(x > s) {
				break;
			} x > s x s {
				break;
			} break; for(int y = 0;y <= k;y++) {
				if(x + y > s) {
					break;
				}else {
					if(x + y + k >= s) {
						answer++;
					}
				}
			} int y = 0; int y = 0; y 0 y <= k y k y++ y++ y {
				if(x + y > s) {
					break;
				}else {
					if(x + y + k >= s) {
						answer++;
					}
				}
			} {
				if(x + y > s) {
					break;
				}else {
					if(x + y + k >= s) {
						answer++;
					}
				}
			} if(x + y > s) {
					break;
				}else {
					if(x + y + k >= s) {
						answer++;
					}
				} x + y > s x + y x y s {
					break;
				} break; {
					if(x + y + k >= s) {
						answer++;
					}
				} if(x + y + k >= s) {
						answer++;
					} x + y + k >= s x + y + k x + y + k x y k s {
						answer++;
					} answer++ answer System.out.println(answer) System.out.println System.out System System.out answer 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();
		int answer = 0;
		for(int x = 0;x <= k;x++) {
			if(x > s) {
				break;
			}
			for(int y = 0;y <= k;y++) {
				if(x + y > s) {
					break;
				}else {
					if(x + y + k >= s) {
						answer++;
					}
				}
			}
		}
		System.out.println(answer);
	}
} public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int answer = 0;
		for(int x = 0;x <= k;x++) {
			if(x > s) {
				break;
			}
			for(int y = 0;y <= k;y++) {
				if(x + y > s) {
					break;
				}else {
					if(x + y + k >= s) {
						answer++;
					}
				}
			}
		}
		System.out.println(answer);
	}
} 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();
		int answer = 0;
		for(int x = 0;x <= k;x++) {
			if(x > s) {
				break;
			}
			for(int y = 0;y <= k;y++) {
				if(x + y > s) {
					break;
				}else {
					if(x + y + k >= s) {
						answer++;
					}
				}
			}
		}
		System.out.println(answer);
	}
}