import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = Integer.parseInt(sc.next());
		int S = Integer.parseInt(sc.next());
		int result = 0;
		for (int x = 0; x <= K; x++) {
			for (int y = 0; y <= K; y++) {
				int total = x + y;
				if (!(total > S) && (total+K) >= S) {
					result++;
				}
			}
		}
		System.out.println(result);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = Integer.parseInt(sc.next());
		int S = Integer.parseInt(sc.next());
		int result = 0;
		for (int x = 0; x <= K; x++) {
			for (int y = 0; y <= K; y++) {
				int total = x + y;
				if (!(total > S) && (total+K) >= S) {
					result++;
				}
			}
		}
		System.out.println(result);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = Integer.parseInt(sc.next());
		int S = Integer.parseInt(sc.next());
		int result = 0;
		for (int x = 0; x <= K; x++) {
			for (int y = 0; y <= K; y++) {
				int total = x + y;
				if (!(total > S) && (total+K) >= S) {
					result++;
				}
			}
		}
		System.out.println(result);
	} main {
		Scanner sc = new Scanner(System.in);
		int K = Integer.parseInt(sc.next());
		int S = Integer.parseInt(sc.next());
		int result = 0;
		for (int x = 0; x <= K; x++) {
			for (int y = 0; y <= K; y++) {
				int total = x + y;
				if (!(total > S) && (total+K) >= S) {
					result++;
				}
			}
		}
		System.out.println(result);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int K = Integer.parseInt(sc.next()); K Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int S = Integer.parseInt(sc.next()); S Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int result = 0; result 0 for (int x = 0; x <= K; x++) {
			for (int y = 0; y <= K; y++) {
				int total = x + y;
				if (!(total > S) && (total+K) >= S) {
					result++;
				}
			}
		} int x = 0; int x = 0; x 0 x <= K x K x++ x++ x {
			for (int y = 0; y <= K; y++) {
				int total = x + y;
				if (!(total > S) && (total+K) >= S) {
					result++;
				}
			}
		} {
			for (int y = 0; y <= K; y++) {
				int total = x + y;
				if (!(total > S) && (total+K) >= S) {
					result++;
				}
			}
		} for (int y = 0; y <= K; y++) {
				int total = x + y;
				if (!(total > S) && (total+K) >= S) {
					result++;
				}
			} int y = 0; int y = 0; y 0 y <= K y K y++ y++ y {
				int total = x + y;
				if (!(total > S) && (total+K) >= S) {
					result++;
				}
			} {
				int total = x + y;
				if (!(total > S) && (total+K) >= S) {
					result++;
				}
			} int total = x + y; total x + y x y if (!(total > S) && (total+K) >= S) {
					result++;
				} !(total > S) && (total+K) >= S !(total > S) (total > S) total S (total+K) >= S (total+K) total K S {
					result++;
				} result++ result System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = Integer.parseInt(sc.next());
		int S = Integer.parseInt(sc.next());
		int result = 0;
		for (int x = 0; x <= K; x++) {
			for (int y = 0; y <= K; y++) {
				int total = x + y;
				if (!(total > S) && (total+K) >= S) {
					result++;
				}
			}
		}
		System.out.println(result);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = Integer.parseInt(sc.next());
		int S = Integer.parseInt(sc.next());
		int result = 0;
		for (int x = 0; x <= K; x++) {
			for (int y = 0; y <= K; y++) {
				int total = x + y;
				if (!(total > S) && (total+K) >= S) {
					result++;
				}
			}
		}
		System.out.println(result);
	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = Integer.parseInt(sc.next());
		int S = Integer.parseInt(sc.next());
		int result = 0;
		for (int x = 0; x <= K; x++) {
			for (int y = 0; y <= K; y++) {
				int total = x + y;
				if (!(total > S) && (total+K) >= S) {
					result++;
				}
			}
		}
		System.out.println(result);
	}
}