import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		long cnt = 0;
		int K = input.nextInt();
		int S = input.nextInt();
		for (int i = 0; i <= K; i++) {
			for (int j = 0; j <= K; j++) {
				int k = S-i-j;
				if (k>=0&&k<=K) cnt++;
			}
		}
		System.out.println(cnt);
	}
	public static boolean Three(int a, int b, int c) {
		if (a!=b&&b!=c&&c!=a) return true;
		return false;
	}
	public static boolean One(int a, int b, int c) {
		if (a==b&&b==c&&c==a) return true;
		return false;
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		long cnt = 0;
		int K = input.nextInt();
		int S = input.nextInt();
		for (int i = 0; i <= K; i++) {
			for (int j = 0; j <= K; j++) {
				int k = S-i-j;
				if (k>=0&&k<=K) cnt++;
			}
		}
		System.out.println(cnt);
	}
	public static boolean Three(int a, int b, int c) {
		if (a!=b&&b!=c&&c!=a) return true;
		return false;
	}
	public static boolean One(int a, int b, int c) {
		if (a==b&&b==c&&c==a) return true;
		return false;
	}
} Main public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		long cnt = 0;
		int K = input.nextInt();
		int S = input.nextInt();
		for (int i = 0; i <= K; i++) {
			for (int j = 0; j <= K; j++) {
				int k = S-i-j;
				if (k>=0&&k<=K) cnt++;
			}
		}
		System.out.println(cnt);
	} main {
		Scanner input = new Scanner(System.in);
		long cnt = 0;
		int K = input.nextInt();
		int S = input.nextInt();
		for (int i = 0; i <= K; i++) {
			for (int j = 0; j <= K; j++) {
				int k = S-i-j;
				if (k>=0&&k<=K) cnt++;
			}
		}
		System.out.println(cnt);
	} Scanner input = new Scanner(System.in); input new Scanner(System.in) long cnt = 0; cnt 0 int K = input.nextInt(); K input.nextInt() input.nextInt input int S = input.nextInt(); S input.nextInt() input.nextInt input for (int i = 0; i <= K; i++) {
			for (int j = 0; j <= K; j++) {
				int k = S-i-j;
				if (k>=0&&k<=K) cnt++;
			}
		} int i = 0; int i = 0; i 0 i <= K i K i++ i++ i {
			for (int j = 0; j <= K; j++) {
				int k = S-i-j;
				if (k>=0&&k<=K) cnt++;
			}
		} {
			for (int j = 0; j <= K; j++) {
				int k = S-i-j;
				if (k>=0&&k<=K) cnt++;
			}
		} for (int j = 0; j <= K; j++) {
				int k = S-i-j;
				if (k>=0&&k<=K) cnt++;
			} int j = 0; int j = 0; j 0 j <= K j K j++ j++ j {
				int k = S-i-j;
				if (k>=0&&k<=K) cnt++;
			} {
				int k = S-i-j;
				if (k>=0&&k<=K) cnt++;
			} int k = S-i-j; k S-i-j S-i-j S i j if (k>=0&&k<=K) cnt++; k>=0&&k<=K k>=0 k 0 k<=K k K cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public static boolean Three(int a, int b, int c) {
		if (a!=b&&b!=c&&c!=a) return true;
		return false;
	} Three {
		if (a!=b&&b!=c&&c!=a) return true;
		return false;
	} if (a!=b&&b!=c&&c!=a) return true; a!=b&&b!=c&&c!=a a!=b&&b!=c&&c!=a a!=b a b b!=c b c c!=a c a return true; true return false; false int a a int b b int c c public static boolean One(int a, int b, int c) {
		if (a==b&&b==c&&c==a) return true;
		return false;
	} One {
		if (a==b&&b==c&&c==a) return true;
		return false;
	} if (a==b&&b==c&&c==a) return true; a==b&&b==c&&c==a a==b&&b==c&&c==a a==b a b b==c b c c==a c a return true; true return false; false int a a int b b int c c public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		long cnt = 0;
		int K = input.nextInt();
		int S = input.nextInt();
		for (int i = 0; i <= K; i++) {
			for (int j = 0; j <= K; j++) {
				int k = S-i-j;
				if (k>=0&&k<=K) cnt++;
			}
		}
		System.out.println(cnt);
	}
	public static boolean Three(int a, int b, int c) {
		if (a!=b&&b!=c&&c!=a) return true;
		return false;
	}
	public static boolean One(int a, int b, int c) {
		if (a==b&&b==c&&c==a) return true;
		return false;
	}
} public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		long cnt = 0;
		int K = input.nextInt();
		int S = input.nextInt();
		for (int i = 0; i <= K; i++) {
			for (int j = 0; j <= K; j++) {
				int k = S-i-j;
				if (k>=0&&k<=K) cnt++;
			}
		}
		System.out.println(cnt);
	}
	public static boolean Three(int a, int b, int c) {
		if (a!=b&&b!=c&&c!=a) return true;
		return false;
	}
	public static boolean One(int a, int b, int c) {
		if (a==b&&b==c&&c==a) return true;
		return false;
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		long cnt = 0;
		int K = input.nextInt();
		int S = input.nextInt();
		for (int i = 0; i <= K; i++) {
			for (int j = 0; j <= K; j++) {
				int k = S-i-j;
				if (k>=0&&k<=K) cnt++;
			}
		}
		System.out.println(cnt);
	}
	public static boolean Three(int a, int b, int c) {
		if (a!=b&&b!=c&&c!=a) return true;
		return false;
	}
	public static boolean One(int a, int b, int c) {
		if (a==b&&b==c&&c==a) return true;
		return false;
	}
}