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 count=0;
		for(int p=0;p<=K;p++) {
			for(int q=0;q<=K;q++) {
				if(S-p-q<=K&&0<=S-p-q) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
} 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 count=0;
		for(int p=0;p<=K;p++) {
			for(int q=0;q<=K;q++) {
				if(S-p-q<=K&&0<=S-p-q) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K=sc.nextInt();
		int S=sc.nextInt();
		int count=0;
		for(int p=0;p<=K;p++) {
			for(int q=0;q<=K;q++) {
				if(S-p-q<=K&&0<=S-p-q) {
					count++;
				}
			}
		}
		System.out.println(count);
	} main {
		Scanner sc = new Scanner(System.in);
		int K=sc.nextInt();
		int S=sc.nextInt();
		int count=0;
		for(int p=0;p<=K;p++) {
			for(int q=0;q<=K;q++) {
				if(S-p-q<=K&&0<=S-p-q) {
					count++;
				}
			}
		}
		System.out.println(count);
	} 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 count=0; count 0 for(int p=0;p<=K;p++) {
			for(int q=0;q<=K;q++) {
				if(S-p-q<=K&&0<=S-p-q) {
					count++;
				}
			}
		} int p=0; int p=0; p 0 p<=K p K p++ p++ p {
			for(int q=0;q<=K;q++) {
				if(S-p-q<=K&&0<=S-p-q) {
					count++;
				}
			}
		} {
			for(int q=0;q<=K;q++) {
				if(S-p-q<=K&&0<=S-p-q) {
					count++;
				}
			}
		} for(int q=0;q<=K;q++) {
				if(S-p-q<=K&&0<=S-p-q) {
					count++;
				}
			} int q=0; int q=0; q 0 q<=K q K q++ q++ q {
				if(S-p-q<=K&&0<=S-p-q) {
					count++;
				}
			} {
				if(S-p-q<=K&&0<=S-p-q) {
					count++;
				}
			} if(S-p-q<=K&&0<=S-p-q) {
					count++;
				} S-p-q<=K&&0<=S-p-q S-p-q<=K S-p-q S-p-q S p q K 0<=S-p-q 0 S-p-q S-p-q S p q {
					count++;
				} count++ count System.out.println(count) System.out.println System.out System System.out count 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 count=0;
		for(int p=0;p<=K;p++) {
			for(int q=0;q<=K;q++) {
				if(S-p-q<=K&&0<=S-p-q) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K=sc.nextInt();
		int S=sc.nextInt();
		int count=0;
		for(int p=0;p<=K;p++) {
			for(int q=0;q<=K;q++) {
				if(S-p-q<=K&&0<=S-p-q) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
} 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 count=0;
		for(int p=0;p<=K;p++) {
			for(int q=0;q<=K;q++) {
				if(S-p-q<=K&&0<=S-p-q) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
}