import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int k = sc.nextInt();
		int s = sc.nextInt();
		int a, b, c ;
		int count = 0;
		for( a = 0; a <= k ;a++) {
			for( b = 0; b <= k ; b++) {
				c = s - a - b;
				if(c >= 0 && c <= 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);
		
		int k = sc.nextInt();
		int s = sc.nextInt();
		int a, b, c ;
		int count = 0;
		for( a = 0; a <= k ;a++) {
			for( b = 0; b <= k ; b++) {
				c = s - a - b;
				if(c >= 0 && c <= k) count++;
			 }
			}
		System.out.println(count);
		}
		

	} Main public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int k = sc.nextInt();
		int s = sc.nextInt();
		int a, b, c ;
		int count = 0;
		for( a = 0; a <= k ;a++) {
			for( b = 0; b <= k ; b++) {
				c = s - a - b;
				if(c >= 0 && c <= k) count++;
			 }
			}
		System.out.println(count);
		} main {
		
		Scanner sc = new Scanner(System.in);
		
		int k = sc.nextInt();
		int s = sc.nextInt();
		int a, b, c ;
		int count = 0;
		for( a = 0; a <= k ;a++) {
			for( b = 0; b <= k ; b++) {
				c = s - a - b;
				if(c >= 0 && c <= k) count++;
			 }
			}
		System.out.println(count);
		} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc int s = sc.nextInt(); s sc.nextInt() sc.nextInt sc int a a b b c ; c int count = 0; count 0 for( a = 0; a <= k ;a++) {
			for( b = 0; b <= k ; b++) {
				c = s - a - b;
				if(c >= 0 && c <= k) count++;
			 }
			} a = 0; a = 0 a 0 a <= k a k a++ a++ a {
			for( b = 0; b <= k ; b++) {
				c = s - a - b;
				if(c >= 0 && c <= k) count++;
			 }
			} {
			for( b = 0; b <= k ; b++) {
				c = s - a - b;
				if(c >= 0 && c <= k) count++;
			 }
			} for( b = 0; b <= k ; b++) {
				c = s - a - b;
				if(c >= 0 && c <= k) count++;
			 } b = 0; b = 0 b 0 b <= k b k b++ b++ b {
				c = s - a - b;
				if(c >= 0 && c <= k) count++;
			 } {
				c = s - a - b;
				if(c >= 0 && c <= k) count++;
			 } c = s - a - b c s - a - b s - a - b s a b if(c >= 0 && c <= k) count++; c >= 0 && c <= k c >= 0 c 0 c <= k c 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);
		
		int k = sc.nextInt();
		int s = sc.nextInt();
		int a, b, c ;
		int count = 0;
		for( a = 0; a <= k ;a++) {
			for( b = 0; b <= k ; b++) {
				c = s - a - b;
				if(c >= 0 && c <= k) count++;
			 }
			}
		System.out.println(count);
		}
		

	} public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int k = sc.nextInt();
		int s = sc.nextInt();
		int a, b, c ;
		int count = 0;
		for( a = 0; a <= k ;a++) {
			for( b = 0; b <= k ; b++) {
				c = s - a - b;
				if(c >= 0 && c <= 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);
		
		int k = sc.nextInt();
		int s = sc.nextInt();
		int a, b, c ;
		int count = 0;
		for( a = 0; a <= k ;a++) {
			for( b = 0; b <= k ; b++) {
				c = s - a - b;
				if(c >= 0 && c <= k) count++;
			 }
			}
		System.out.println(count);
		}
		

	}


