import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int K = scan.nextInt();
		int S = scan.nextInt();
		
		int count = 0;
		
		for (int X = 0; X <= K; X++) {
			for (int Y = 0; Y <= K; Y++) {
				if (S - X - Y >= 0 && S - X - Y <= K) {
					count++;
				}
			}
		}
		
		System.out.print(count);
		
	}

} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int K = scan.nextInt();
		int S = scan.nextInt();
		
		int count = 0;
		
		for (int X = 0; X <= K; X++) {
			for (int Y = 0; Y <= K; Y++) {
				if (S - X - Y >= 0 && S - X - Y <= K) {
					count++;
				}
			}
		}
		
		System.out.print(count);
		
	}

} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int K = scan.nextInt();
		int S = scan.nextInt();
		
		int count = 0;
		
		for (int X = 0; X <= K; X++) {
			for (int Y = 0; Y <= K; Y++) {
				if (S - X - Y >= 0 && S - X - Y <= K) {
					count++;
				}
			}
		}
		
		System.out.print(count);
		
	} main {
		Scanner scan = new Scanner(System.in);
		
		int K = scan.nextInt();
		int S = scan.nextInt();
		
		int count = 0;
		
		for (int X = 0; X <= K; X++) {
			for (int Y = 0; Y <= K; Y++) {
				if (S - X - Y >= 0 && S - X - Y <= K) {
					count++;
				}
			}
		}
		
		System.out.print(count);
		
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int K = scan.nextInt(); K scan.nextInt() scan.nextInt scan int S = scan.nextInt(); S scan.nextInt() scan.nextInt scan int count = 0; count 0 for (int X = 0; X <= K; X++) {
			for (int Y = 0; Y <= K; Y++) {
				if (S - X - Y >= 0 && S - X - Y <= K) {
					count++;
				}
			}
		} int X = 0; int X = 0; X 0 X <= K X K X++ X++ X {
			for (int Y = 0; Y <= K; Y++) {
				if (S - X - Y >= 0 && S - X - Y <= K) {
					count++;
				}
			}
		} {
			for (int Y = 0; Y <= K; Y++) {
				if (S - X - Y >= 0 && S - X - Y <= K) {
					count++;
				}
			}
		} for (int Y = 0; Y <= K; Y++) {
				if (S - X - Y >= 0 && S - X - Y <= K) {
					count++;
				}
			} int Y = 0; int Y = 0; Y 0 Y <= K Y K Y++ Y++ Y {
				if (S - X - Y >= 0 && S - X - Y <= K) {
					count++;
				}
			} {
				if (S - X - Y >= 0 && S - X - Y <= K) {
					count++;
				}
			} if (S - X - Y >= 0 && S - X - Y <= K) {
					count++;
				} S - X - Y >= 0 && S - X - Y <= K S - X - Y >= 0 S - X - Y S - X - Y S X Y 0 S - X - Y <= K S - X - Y S - X - Y S X Y K {
					count++;
				} count++ count System.out.print(count) System.out.print System.out System System.out count String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int K = scan.nextInt();
		int S = scan.nextInt();
		
		int count = 0;
		
		for (int X = 0; X <= K; X++) {
			for (int Y = 0; Y <= K; Y++) {
				if (S - X - Y >= 0 && S - X - Y <= K) {
					count++;
				}
			}
		}
		
		System.out.print(count);
		
	}

} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int K = scan.nextInt();
		int S = scan.nextInt();
		
		int count = 0;
		
		for (int X = 0; X <= K; X++) {
			for (int Y = 0; Y <= K; Y++) {
				if (S - X - Y >= 0 && S - X - Y <= K) {
					count++;
				}
			}
		}
		
		System.out.print(count);
		
	}

} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int K = scan.nextInt();
		int S = scan.nextInt();
		
		int count = 0;
		
		for (int X = 0; X <= K; X++) {
			for (int Y = 0; Y <= K; Y++) {
				if (S - X - Y >= 0 && S - X - Y <= K) {
					count++;
				}
			}
		}
		
		System.out.print(count);
		
	}

}