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