import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int max = sc.nextInt();
		int answer = sc.nextInt();
		int count=0;
		for(int a=0;a<=max;a++){
			for(int b=0;b<=max;b++){ 
				if(answer-a-b<=max && answer-a-b>=0) count++;
			}
		}
		System.out.println(count);;
		
		sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int max = sc.nextInt();
		int answer = sc.nextInt();
		int count=0;
		for(int a=0;a<=max;a++){
			for(int b=0;b<=max;b++){ 
				if(answer-a-b<=max && answer-a-b>=0) count++;
			}
		}
		System.out.println(count);;
		
		sc.close();
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int max = sc.nextInt();
		int answer = sc.nextInt();
		int count=0;
		for(int a=0;a<=max;a++){
			for(int b=0;b<=max;b++){ 
				if(answer-a-b<=max && answer-a-b>=0) count++;
			}
		}
		System.out.println(count);;
		
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int max = sc.nextInt();
		int answer = sc.nextInt();
		int count=0;
		for(int a=0;a<=max;a++){
			for(int b=0;b<=max;b++){ 
				if(answer-a-b<=max && answer-a-b>=0) count++;
			}
		}
		System.out.println(count);;
		
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int max = sc.nextInt(); max sc.nextInt() sc.nextInt sc int answer = sc.nextInt(); answer sc.nextInt() sc.nextInt sc int count=0; count 0 for(int a=0;a<=max;a++){
			for(int b=0;b<=max;b++){ 
				if(answer-a-b<=max && answer-a-b>=0) count++;
			}
		} int a=0; int a=0; a 0 a<=max a max a++ a++ a {
			for(int b=0;b<=max;b++){ 
				if(answer-a-b<=max && answer-a-b>=0) count++;
			}
		} {
			for(int b=0;b<=max;b++){ 
				if(answer-a-b<=max && answer-a-b>=0) count++;
			}
		} for(int b=0;b<=max;b++){ 
				if(answer-a-b<=max && answer-a-b>=0) count++;
			} int b=0; int b=0; b 0 b<=max b max b++ b++ b { 
				if(answer-a-b<=max && answer-a-b>=0) count++;
			} { 
				if(answer-a-b<=max && answer-a-b>=0) count++;
			} if(answer-a-b<=max && answer-a-b>=0) count++; answer-a-b<=max && answer-a-b>=0 answer-a-b<=max answer-a-b answer-a-b answer a b max answer-a-b>=0 answer-a-b answer-a-b answer a b 0 count++ count System.out.println(count) System.out.println System.out System System.out count sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int max = sc.nextInt();
		int answer = sc.nextInt();
		int count=0;
		for(int a=0;a<=max;a++){
			for(int b=0;b<=max;b++){ 
				if(answer-a-b<=max && answer-a-b>=0) count++;
			}
		}
		System.out.println(count);;
		
		sc.close();
	}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int max = sc.nextInt();
		int answer = sc.nextInt();
		int count=0;
		for(int a=0;a<=max;a++){
			for(int b=0;b<=max;b++){ 
				if(answer-a-b<=max && answer-a-b>=0) count++;
			}
		}
		System.out.println(count);;
		
		sc.close();
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int max = sc.nextInt();
		int answer = sc.nextInt();
		int count=0;
		for(int a=0;a<=max;a++){
			for(int b=0;b<=max;b++){ 
				if(answer-a-b<=max && answer-a-b>=0) count++;
			}
		}
		System.out.println(count);;
		
		sc.close();
	}
}