import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int K = scan.nextInt();
			int S = scan.nextInt();
			
			
			
			int count = 0;
			
			for(int i = 0;i<=K;i++) {
				for(int j = 0;j<=K;j++) {
					if(S-i-j>=0&&S-i-j<=K)count++;	
				}
			}
			
			
			System.out.println(count);
			
			
			
		}
		
		
	}
	
	
	
	
	
		

} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int K = scan.nextInt();
			int S = scan.nextInt();
			
			
			
			int count = 0;
			
			for(int i = 0;i<=K;i++) {
				for(int j = 0;j<=K;j++) {
					if(S-i-j>=0&&S-i-j<=K)count++;	
				}
			}
			
			
			System.out.println(count);
			
			
			
		}
		
		
	}
	
	
	
	
	
		

} Main public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int K = scan.nextInt();
			int S = scan.nextInt();
			
			
			
			int count = 0;
			
			for(int i = 0;i<=K;i++) {
				for(int j = 0;j<=K;j++) {
					if(S-i-j>=0&&S-i-j<=K)count++;	
				}
			}
			
			
			System.out.println(count);
			
			
			
		}
		
		
	} main {
		try(Scanner scan = new Scanner(System.in)){
			
			int K = scan.nextInt();
			int S = scan.nextInt();
			
			
			
			int count = 0;
			
			for(int i = 0;i<=K;i++) {
				for(int j = 0;j<=K;j++) {
					if(S-i-j>=0&&S-i-j<=K)count++;	
				}
			}
			
			
			System.out.println(count);
			
			
			
		}
		
		
	} try(Scanner scan = new Scanner(System.in)){
			
			int K = scan.nextInt();
			int S = scan.nextInt();
			
			
			
			int count = 0;
			
			for(int i = 0;i<=K;i++) {
				for(int j = 0;j<=K;j++) {
					if(S-i-j>=0&&S-i-j<=K)count++;	
				}
			}
			
			
			System.out.println(count);
			
			
			
		} {
			
			int K = scan.nextInt();
			int S = scan.nextInt();
			
			
			
			int count = 0;
			
			for(int i = 0;i<=K;i++) {
				for(int j = 0;j<=K;j++) {
					if(S-i-j>=0&&S-i-j<=K)count++;	
				}
			}
			
			
			System.out.println(count);
			
			
			
		} Scanner scan = new Scanner(System.in) Scanner scan = new Scanner(System.in) new Scanner(System.in) int K = scan.nextInt(); K scan.nextInt() scan.nextInt scan int S = scan.nextInt(); S scan.nextInt() scan.nextInt scan int count = 0; count 0 for(int i = 0;i<=K;i++) {
				for(int j = 0;j<=K;j++) {
					if(S-i-j>=0&&S-i-j<=K)count++;	
				}
			} int i = 0; int i = 0; i 0 i<=K i K i++ i++ i {
				for(int j = 0;j<=K;j++) {
					if(S-i-j>=0&&S-i-j<=K)count++;	
				}
			} {
				for(int j = 0;j<=K;j++) {
					if(S-i-j>=0&&S-i-j<=K)count++;	
				}
			} for(int j = 0;j<=K;j++) {
					if(S-i-j>=0&&S-i-j<=K)count++;	
				} int j = 0; int j = 0; j 0 j<=K j K j++ j++ j {
					if(S-i-j>=0&&S-i-j<=K)count++;	
				} {
					if(S-i-j>=0&&S-i-j<=K)count++;	
				} if(S-i-j>=0&&S-i-j<=K)count++; S-i-j>=0&&S-i-j<=K S-i-j>=0 S-i-j S-i-j S i j 0 S-i-j<=K S-i-j S-i-j S i j 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) {
		try(Scanner scan = new Scanner(System.in)){
			
			int K = scan.nextInt();
			int S = scan.nextInt();
			
			
			
			int count = 0;
			
			for(int i = 0;i<=K;i++) {
				for(int j = 0;j<=K;j++) {
					if(S-i-j>=0&&S-i-j<=K)count++;	
				}
			}
			
			
			System.out.println(count);
			
			
			
		}
		
		
	}
	
	
	
	
	
		

} public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int K = scan.nextInt();
			int S = scan.nextInt();
			
			
			
			int count = 0;
			
			for(int i = 0;i<=K;i++) {
				for(int j = 0;j<=K;j++) {
					if(S-i-j>=0&&S-i-j<=K)count++;	
				}
			}
			
			
			System.out.println(count);
			
			
			
		}
		
		
	}
	
	
	
	
	
		

} Main
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int K = scan.nextInt();
			int S = scan.nextInt();
			
			
			
			int count = 0;
			
			for(int i = 0;i<=K;i++) {
				for(int j = 0;j<=K;j++) {
					if(S-i-j>=0&&S-i-j<=K)count++;	
				}
			}
			
			
			System.out.println(count);
			
			
			
		}
		
		
	}
	
	
	
	
	
		

}
