import java.util.Scanner;

public class Main {
	public static void main(String[] ar)
	{
		Scanner sc = new Scanner(System.in);

		int cnt = 0;
		int k = sc.nextInt(), def = sc.nextInt();
		int x = 0, y = 0, z = def;

		// y -> x
		while (true)
		{
			z = def - x;
			y = 0;

			// z -> y
			while (true)
			{
				if (x <= k && y <= k && z <= k) { ++cnt; }

				if (z == 0) { break;}

				--z; ++y;
			}

			++x;

			if (x > def) { break; }
		}

		System.out.println(cnt);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] ar)
	{
		Scanner sc = new Scanner(System.in);

		int cnt = 0;
		int k = sc.nextInt(), def = sc.nextInt();
		int x = 0, y = 0, z = def;

		// y -> x
		while (true)
		{
			z = def - x;
			y = 0;

			// z -> y
			while (true)
			{
				if (x <= k && y <= k && z <= k) { ++cnt; }

				if (z == 0) { break;}

				--z; ++y;
			}

			++x;

			if (x > def) { break; }
		}

		System.out.println(cnt);
	}
} Main public static void main(String[] ar)
	{
		Scanner sc = new Scanner(System.in);

		int cnt = 0;
		int k = sc.nextInt(), def = sc.nextInt();
		int x = 0, y = 0, z = def;

		// y -> x
		while (true)
		{
			z = def - x;
			y = 0;

			// z -> y
			while (true)
			{
				if (x <= k && y <= k && z <= k) { ++cnt; }

				if (z == 0) { break;}

				--z; ++y;
			}

			++x;

			if (x > def) { break; }
		}

		System.out.println(cnt);
	} main {
		Scanner sc = new Scanner(System.in);

		int cnt = 0;
		int k = sc.nextInt(), def = sc.nextInt();
		int x = 0, y = 0, z = def;

		// y -> x
		while (true)
		{
			z = def - x;
			y = 0;

			// z -> y
			while (true)
			{
				if (x <= k && y <= k && z <= k) { ++cnt; }

				if (z == 0) { break;}

				--z; ++y;
			}

			++x;

			if (x > def) { break; }
		}

		System.out.println(cnt);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int cnt = 0; cnt 0 int k = sc.nextInt() k sc.nextInt() sc.nextInt sc def = sc.nextInt(); def sc.nextInt() sc.nextInt sc int x = 0 x 0 y = 0 y 0 z = def; z def while (true)
		{
			z = def - x;
			y = 0;

			// z -> y
			while (true)
			{
				if (x <= k && y <= k && z <= k) { ++cnt; }

				if (z == 0) { break;}

				--z; ++y;
			}

			++x;

			if (x > def) { break; }
		} true {
			z = def - x;
			y = 0;

			// z -> y
			while (true)
			{
				if (x <= k && y <= k && z <= k) { ++cnt; }

				if (z == 0) { break;}

				--z; ++y;
			}

			++x;

			if (x > def) { break; }
		} z = def - x z def - x def x y = 0 y 0 while (true)
			{
				if (x <= k && y <= k && z <= k) { ++cnt; }

				if (z == 0) { break;}

				--z; ++y;
			} true {
				if (x <= k && y <= k && z <= k) { ++cnt; }

				if (z == 0) { break;}

				--z; ++y;
			} if (x <= k && y <= k && z <= k) { ++cnt; } x <= k && y <= k && z <= k x <= k && y <= k && z <= k x <= k x k y <= k y k z <= k z k { ++cnt; } ++cnt cnt if (z == 0) { break;} z == 0 z 0 { break;} break; --z z ++y y ++x x if (x > def) { break; } x > def x def { break; } break; System.out.println(cnt) System.out.println System.out System System.out cnt String[] ar ar public class Main {
	public static void main(String[] ar)
	{
		Scanner sc = new Scanner(System.in);

		int cnt = 0;
		int k = sc.nextInt(), def = sc.nextInt();
		int x = 0, y = 0, z = def;

		// y -> x
		while (true)
		{
			z = def - x;
			y = 0;

			// z -> y
			while (true)
			{
				if (x <= k && y <= k && z <= k) { ++cnt; }

				if (z == 0) { break;}

				--z; ++y;
			}

			++x;

			if (x > def) { break; }
		}

		System.out.println(cnt);
	}
} public class Main {
	public static void main(String[] ar)
	{
		Scanner sc = new Scanner(System.in);

		int cnt = 0;
		int k = sc.nextInt(), def = sc.nextInt();
		int x = 0, y = 0, z = def;

		// y -> x
		while (true)
		{
			z = def - x;
			y = 0;

			// z -> y
			while (true)
			{
				if (x <= k && y <= k && z <= k) { ++cnt; }

				if (z == 0) { break;}

				--z; ++y;
			}

			++x;

			if (x > def) { break; }
		}

		System.out.println(cnt);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] ar)
	{
		Scanner sc = new Scanner(System.in);

		int cnt = 0;
		int k = sc.nextInt(), def = sc.nextInt();
		int x = 0, y = 0, z = def;

		// y -> x
		while (true)
		{
			z = def - x;
			y = 0;

			// z -> y
			while (true)
			{
				if (x <= k && y <= k && z <= k) { ++cnt; }

				if (z == 0) { break;}

				--z; ++y;
			}

			++x;

			if (x > def) { break; }
		}

		System.out.println(cnt);
	}
}
