import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException  {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] s = br.readLine().split(" ");
		int max = Integer.parseInt(s[0]);
		int ans = Integer.parseInt(s[1]);
		
		int result = 0;
		for(int i=0; i<=max; i++) {
			for(int j=0; j<=max; j++) {
				int k = ans - (i + j);
				if(0 <= k && k <= max) result++;
			}
		}
		System.out.println(result);
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static void main(String[] args) throws IOException  {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] s = br.readLine().split(" ");
		int max = Integer.parseInt(s[0]);
		int ans = Integer.parseInt(s[1]);
		
		int result = 0;
		for(int i=0; i<=max; i++) {
			for(int j=0; j<=max; j++) {
				int k = ans - (i + j);
				if(0 <= k && k <= max) result++;
			}
		}
		System.out.println(result);
	}

} Main public static void main(String[] args) throws IOException  {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] s = br.readLine().split(" ");
		int max = Integer.parseInt(s[0]);
		int ans = Integer.parseInt(s[1]);
		
		int result = 0;
		for(int i=0; i<=max; i++) {
			for(int j=0; j<=max; j++) {
				int k = ans - (i + j);
				if(0 <= k && k <= max) result++;
			}
		}
		System.out.println(result);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] s = br.readLine().split(" ");
		int max = Integer.parseInt(s[0]);
		int ans = Integer.parseInt(s[1]);
		
		int result = 0;
		for(int i=0; i<=max; i++) {
			for(int j=0; j<=max; j++) {
				int k = ans - (i + j);
				if(0 <= k && k <= max) result++;
			}
		}
		System.out.println(result);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] s = br.readLine().split(" "); s br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int max = Integer.parseInt(s[0]); max Integer.parseInt(s[0]) Integer.parseInt Integer s[0] s 0 int ans = Integer.parseInt(s[1]); ans Integer.parseInt(s[1]) Integer.parseInt Integer s[1] s 1 int result = 0; result 0 for(int i=0; i<=max; i++) {
			for(int j=0; j<=max; j++) {
				int k = ans - (i + j);
				if(0 <= k && k <= max) result++;
			}
		} int i=0; int i=0; i 0 i<=max i max i++ i++ i {
			for(int j=0; j<=max; j++) {
				int k = ans - (i + j);
				if(0 <= k && k <= max) result++;
			}
		} {
			for(int j=0; j<=max; j++) {
				int k = ans - (i + j);
				if(0 <= k && k <= max) result++;
			}
		} for(int j=0; j<=max; j++) {
				int k = ans - (i + j);
				if(0 <= k && k <= max) result++;
			} int j=0; int j=0; j 0 j<=max j max j++ j++ j {
				int k = ans - (i + j);
				if(0 <= k && k <= max) result++;
			} {
				int k = ans - (i + j);
				if(0 <= k && k <= max) result++;
			} int k = ans - (i + j); k ans - (i + j) ans (i + j) i j if(0 <= k && k <= max) result++; 0 <= k && k <= max 0 <= k 0 k k <= max k max result++ result System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {

	public static void main(String[] args) throws IOException  {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] s = br.readLine().split(" ");
		int max = Integer.parseInt(s[0]);
		int ans = Integer.parseInt(s[1]);
		
		int result = 0;
		for(int i=0; i<=max; i++) {
			for(int j=0; j<=max; j++) {
				int k = ans - (i + j);
				if(0 <= k && k <= max) result++;
			}
		}
		System.out.println(result);
	}

} public class Main {

	public static void main(String[] args) throws IOException  {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] s = br.readLine().split(" ");
		int max = Integer.parseInt(s[0]);
		int ans = Integer.parseInt(s[1]);
		
		int result = 0;
		for(int i=0; i<=max; i++) {
			for(int j=0; j<=max; j++) {
				int k = ans - (i + j);
				if(0 <= k && k <= max) result++;
			}
		}
		System.out.println(result);
	}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException  {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] s = br.readLine().split(" ");
		int max = Integer.parseInt(s[0]);
		int ans = Integer.parseInt(s[1]);
		
		int result = 0;
		for(int i=0; i<=max; i++) {
			for(int j=0; j<=max; j++) {
				int k = ans - (i + j);
				if(0 <= k && k <= max) result++;
			}
		}
		System.out.println(result);
	}

}
