import java.util.Scanner;

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 ans = 0;
		for(int x=0; x<=k; x++){
			for(int y=0; y<=k; y++){
				if (s-x-y<=k && 0<=s-x-y){
					ans += 1;
				}
			}
		}
		System.out.println(ans);
	}
} import java.util.Scanner; Scanner 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 ans = 0;
		for(int x=0; x<=k; x++){
			for(int y=0; y<=k; y++){
				if (s-x-y<=k && 0<=s-x-y){
					ans += 1;
				}
			}
		}
		System.out.println(ans);
	}
} 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 ans = 0;
		for(int x=0; x<=k; x++){
			for(int y=0; y<=k; y++){
				if (s-x-y<=k && 0<=s-x-y){
					ans += 1;
				}
			}
		}
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);

		int k = Integer.parseInt(sc.next());
		int s = Integer.parseInt(sc.next());

		int ans = 0;
		for(int x=0; x<=k; x++){
			for(int y=0; y<=k; y++){
				if (s-x-y<=k && 0<=s-x-y){
					ans += 1;
				}
			}
		}
		System.out.println(ans);
	} 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 ans = 0; ans 0 for(int x=0; x<=k; x++){
			for(int y=0; y<=k; y++){
				if (s-x-y<=k && 0<=s-x-y){
					ans += 1;
				}
			}
		} 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<=k && 0<=s-x-y){
					ans += 1;
				}
			}
		} {
			for(int y=0; y<=k; y++){
				if (s-x-y<=k && 0<=s-x-y){
					ans += 1;
				}
			}
		} for(int y=0; y<=k; y++){
				if (s-x-y<=k && 0<=s-x-y){
					ans += 1;
				}
			} int y=0; int y=0; y 0 y<=k y k y++ y++ y {
				if (s-x-y<=k && 0<=s-x-y){
					ans += 1;
				}
			} {
				if (s-x-y<=k && 0<=s-x-y){
					ans += 1;
				}
			} if (s-x-y<=k && 0<=s-x-y){
					ans += 1;
				} s-x-y<=k && 0<=s-x-y s-x-y<=k s-x-y s-x-y s x y k 0<=s-x-y 0 s-x-y s-x-y s x y {
					ans += 1;
				} ans += 1 ans 1 System.out.println(ans) System.out.println System.out System System.out ans 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 ans = 0;
		for(int x=0; x<=k; x++){
			for(int y=0; y<=k; y++){
				if (s-x-y<=k && 0<=s-x-y){
					ans += 1;
				}
			}
		}
		System.out.println(ans);
	}
} 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 ans = 0;
		for(int x=0; x<=k; x++){
			for(int y=0; y<=k; y++){
				if (s-x-y<=k && 0<=s-x-y){
					ans += 1;
				}
			}
		}
		System.out.println(ans);
	}
} Main
import java.util.Scanner;

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 ans = 0;
		for(int x=0; x<=k; x++){
			for(int y=0; y<=k; y++){
				if (s-x-y<=k && 0<=s-x-y){
					ans += 1;
				}
			}
		}
		System.out.println(ans);
	}
}
