import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner scanner = new Scanner(System.in);
		int k = scanner.nextInt()+1;
		int s = scanner.nextInt();
		int count = 0;
		for(int i = 0; i < k; i++){
			for(int j = 0; j < k; j++){
				int a = s - (i+j);
				if(a <= k-1 && a >= 0){
					count++;
				}
			}
		}
		System.out.println(count);
	}
} import java.io.IOException; IOException java.io import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) throws IOException {
		Scanner scanner = new Scanner(System.in);
		int k = scanner.nextInt()+1;
		int s = scanner.nextInt();
		int count = 0;
		for(int i = 0; i < k; i++){
			for(int j = 0; j < k; j++){
				int a = s - (i+j);
				if(a <= k-1 && a >= 0){
					count++;
				}
			}
		}
		System.out.println(count);
	}
} Main public static void main(String[] args) throws IOException {
		Scanner scanner = new Scanner(System.in);
		int k = scanner.nextInt()+1;
		int s = scanner.nextInt();
		int count = 0;
		for(int i = 0; i < k; i++){
			for(int j = 0; j < k; j++){
				int a = s - (i+j);
				if(a <= k-1 && a >= 0){
					count++;
				}
			}
		}
		System.out.println(count);
	} main {
		Scanner scanner = new Scanner(System.in);
		int k = scanner.nextInt()+1;
		int s = scanner.nextInt();
		int count = 0;
		for(int i = 0; i < k; i++){
			for(int j = 0; j < k; j++){
				int a = s - (i+j);
				if(a <= k-1 && a >= 0){
					count++;
				}
			}
		}
		System.out.println(count);
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int k = scanner.nextInt()+1; k scanner.nextInt()+1 scanner.nextInt() scanner.nextInt scanner 1 int s = scanner.nextInt(); s scanner.nextInt() scanner.nextInt scanner int count = 0; count 0 for(int i = 0; i < k; i++){
			for(int j = 0; j < k; j++){
				int a = s - (i+j);
				if(a <= k-1 && a >= 0){
					count++;
				}
			}
		} int i = 0; int i = 0; i 0 i < k i k i++ i++ i {
			for(int j = 0; j < k; j++){
				int a = s - (i+j);
				if(a <= k-1 && a >= 0){
					count++;
				}
			}
		} {
			for(int j = 0; j < k; j++){
				int a = s - (i+j);
				if(a <= k-1 && a >= 0){
					count++;
				}
			}
		} for(int j = 0; j < k; j++){
				int a = s - (i+j);
				if(a <= k-1 && a >= 0){
					count++;
				}
			} int j = 0; int j = 0; j 0 j < k j k j++ j++ j {
				int a = s - (i+j);
				if(a <= k-1 && a >= 0){
					count++;
				}
			} {
				int a = s - (i+j);
				if(a <= k-1 && a >= 0){
					count++;
				}
			} int a = s - (i+j); a s - (i+j) s (i+j) i j if(a <= k-1 && a >= 0){
					count++;
				} a <= k-1 && a >= 0 a <= k-1 a k-1 k 1 a >= 0 a 0 {
					count++;
				} 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) throws IOException {
		Scanner scanner = new Scanner(System.in);
		int k = scanner.nextInt()+1;
		int s = scanner.nextInt();
		int count = 0;
		for(int i = 0; i < k; i++){
			for(int j = 0; j < k; j++){
				int a = s - (i+j);
				if(a <= k-1 && a >= 0){
					count++;
				}
			}
		}
		System.out.println(count);
	}
} public class Main {

	public static void main(String[] args) throws IOException {
		Scanner scanner = new Scanner(System.in);
		int k = scanner.nextInt()+1;
		int s = scanner.nextInt();
		int count = 0;
		for(int i = 0; i < k; i++){
			for(int j = 0; j < k; j++){
				int a = s - (i+j);
				if(a <= k-1 && a >= 0){
					count++;
				}
			}
		}
		System.out.println(count);
	}
} Main
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner scanner = new Scanner(System.in);
		int k = scanner.nextInt()+1;
		int s = scanner.nextInt();
		int count = 0;
		for(int i = 0; i < k; i++){
			for(int j = 0; j < k; j++){
				int a = s - (i+j);
				if(a <= k-1 && a >= 0){
					count++;
				}
			}
		}
		System.out.println(count);
	}
}