import 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 counter = 0;
		for(int x = 0; x <= k; x++) {
			for(int y = 0; y <= k; y++) {
				if(s - x - y >= 0 && s - x - y <= k)
					counter++;
			}
		}
		System.out.println(String.valueOf(counter));
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int counter = 0;
		for(int x = 0; x <= k; x++) {
			for(int y = 0; y <= k; y++) {
				if(s - x - y >= 0 && s - x - y <= k)
					counter++;
			}
		}
		System.out.println(String.valueOf(counter));
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int counter = 0;
		for(int x = 0; x <= k; x++) {
			for(int y = 0; y <= k; y++) {
				if(s - x - y >= 0 && s - x - y <= k)
					counter++;
			}
		}
		System.out.println(String.valueOf(counter));
	} main {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int counter = 0;
		for(int x = 0; x <= k; x++) {
			for(int y = 0; y <= k; y++) {
				if(s - x - y >= 0 && s - x - y <= k)
					counter++;
			}
		}
		System.out.println(String.valueOf(counter));
	} 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 counter = 0; counter 0 for(int x = 0; x <= k; x++) {
			for(int y = 0; y <= k; y++) {
				if(s - x - y >= 0 && s - x - y <= k)
					counter++;
			}
		} 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)
					counter++;
			}
		} {
			for(int y = 0; y <= k; y++) {
				if(s - x - y >= 0 && s - x - y <= k)
					counter++;
			}
		} for(int y = 0; y <= k; y++) {
				if(s - x - y >= 0 && s - x - y <= k)
					counter++;
			} int y = 0; int y = 0; y 0 y <= k y k y++ y++ y {
				if(s - x - y >= 0 && s - x - y <= k)
					counter++;
			} {
				if(s - x - y >= 0 && s - x - y <= k)
					counter++;
			} if(s - x - y >= 0 && s - x - y <= k)
					counter++; 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 counter++ counter System.out.println(String.valueOf(counter)) System.out.println System.out System System.out String.valueOf(counter) String.valueOf String counter 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 counter = 0;
		for(int x = 0; x <= k; x++) {
			for(int y = 0; y <= k; y++) {
				if(s - x - y >= 0 && s - x - y <= k)
					counter++;
			}
		}
		System.out.println(String.valueOf(counter));
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int counter = 0;
		for(int x = 0; x <= k; x++) {
			for(int y = 0; y <= k; y++) {
				if(s - x - y >= 0 && s - x - y <= k)
					counter++;
			}
		}
		System.out.println(String.valueOf(counter));
	}
} Main
import 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 counter = 0;
		for(int x = 0; x <= k; x++) {
			for(int y = 0; y <= k; y++) {
				if(s - x - y >= 0 && s - x - y <= k)
					counter++;
			}
		}
		System.out.println(String.valueOf(counter));
	}
}