import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String[] tmpString = sc.nextLine().split(" ");
		int K = Integer.parseInt(tmpString[0]);
		int S = Integer.parseInt(tmpString[1]);
		
		int count = 0;
		for (int i = 0; i <= K; i++) {
			for (int j = 0; j <= K; j++) {
				int total = S - i - j;
				if (total >= 0 && total <= K) count++;
			}
		}
		
		System.out.println(count);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String[] tmpString = sc.nextLine().split(" ");
		int K = Integer.parseInt(tmpString[0]);
		int S = Integer.parseInt(tmpString[1]);
		
		int count = 0;
		for (int i = 0; i <= K; i++) {
			for (int j = 0; j <= K; j++) {
				int total = S - i - j;
				if (total >= 0 && total <= K) count++;
			}
		}
		
		System.out.println(count);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String[] tmpString = sc.nextLine().split(" ");
		int K = Integer.parseInt(tmpString[0]);
		int S = Integer.parseInt(tmpString[1]);
		
		int count = 0;
		for (int i = 0; i <= K; i++) {
			for (int j = 0; j <= K; j++) {
				int total = S - i - j;
				if (total >= 0 && total <= K) count++;
			}
		}
		
		System.out.println(count);
	} main {
		Scanner sc = new Scanner(System.in);
		
		String[] tmpString = sc.nextLine().split(" ");
		int K = Integer.parseInt(tmpString[0]);
		int S = Integer.parseInt(tmpString[1]);
		
		int count = 0;
		for (int i = 0; i <= K; i++) {
			for (int j = 0; j <= K; j++) {
				int total = S - i - j;
				if (total >= 0 && total <= K) count++;
			}
		}
		
		System.out.println(count);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String[] tmpString = sc.nextLine().split(" "); tmpString sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " int K = Integer.parseInt(tmpString[0]); K Integer.parseInt(tmpString[0]) Integer.parseInt Integer tmpString[0] tmpString 0 int S = Integer.parseInt(tmpString[1]); S Integer.parseInt(tmpString[1]) Integer.parseInt Integer tmpString[1] tmpString 1 int count = 0; count 0 for (int i = 0; i <= K; i++) {
			for (int j = 0; j <= K; j++) {
				int total = S - i - j;
				if (total >= 0 && total <= K) count++;
			}
		} int i = 0; int i = 0; i 0 i <= K i K i++ i++ i {
			for (int j = 0; j <= K; j++) {
				int total = S - i - j;
				if (total >= 0 && total <= K) count++;
			}
		} {
			for (int j = 0; j <= K; j++) {
				int total = S - i - j;
				if (total >= 0 && total <= K) count++;
			}
		} for (int j = 0; j <= K; j++) {
				int total = S - i - j;
				if (total >= 0 && total <= K) count++;
			} int j = 0; int j = 0; j 0 j <= K j K j++ j++ j {
				int total = S - i - j;
				if (total >= 0 && total <= K) count++;
			} {
				int total = S - i - j;
				if (total >= 0 && total <= K) count++;
			} int total = S - i - j; total S - i - j S - i - j S i j if (total >= 0 && total <= K) count++; total >= 0 && total <= K total >= 0 total 0 total <= K total K count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String[] tmpString = sc.nextLine().split(" ");
		int K = Integer.parseInt(tmpString[0]);
		int S = Integer.parseInt(tmpString[1]);
		
		int count = 0;
		for (int i = 0; i <= K; i++) {
			for (int j = 0; j <= K; j++) {
				int total = S - i - j;
				if (total >= 0 && total <= K) count++;
			}
		}
		
		System.out.println(count);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String[] tmpString = sc.nextLine().split(" ");
		int K = Integer.parseInt(tmpString[0]);
		int S = Integer.parseInt(tmpString[1]);
		
		int count = 0;
		for (int i = 0; i <= K; i++) {
			for (int j = 0; j <= K; j++) {
				int total = S - i - j;
				if (total >= 0 && total <= K) count++;
			}
		}
		
		System.out.println(count);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String[] tmpString = sc.nextLine().split(" ");
		int K = Integer.parseInt(tmpString[0]);
		int S = Integer.parseInt(tmpString[1]);
		
		int count = 0;
		for (int i = 0; i <= K; i++) {
			for (int j = 0; j <= K; j++) {
				int total = S - i - j;
				if (total >= 0 && total <= K) count++;
			}
		}
		
		System.out.println(count);
	}
}
