
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int maxNum = scan.nextInt();
		int sum = scan.nextInt();
		int ans = 0;
		
		for(int x = 0; x <= maxNum; ++x){
			for(int y = 0; y <= maxNum; ++y){
				int z = sum - x - y;
				if(0 <= z && z <= maxNum){
					ans = ans + 1;
				}
			}
		}
		System.out.println(ans);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int maxNum = scan.nextInt();
		int sum = scan.nextInt();
		int ans = 0;
		
		for(int x = 0; x <= maxNum; ++x){
			for(int y = 0; y <= maxNum; ++y){
				int z = sum - x - y;
				if(0 <= z && z <= maxNum){
					ans = ans + 1;
				}
			}
		}
		System.out.println(ans);
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int maxNum = scan.nextInt();
		int sum = scan.nextInt();
		int ans = 0;
		
		for(int x = 0; x <= maxNum; ++x){
			for(int y = 0; y <= maxNum; ++y){
				int z = sum - x - y;
				if(0 <= z && z <= maxNum){
					ans = ans + 1;
				}
			}
		}
		System.out.println(ans);
	} main {
		Scanner scan = new Scanner(System.in);
		int maxNum = scan.nextInt();
		int sum = scan.nextInt();
		int ans = 0;
		
		for(int x = 0; x <= maxNum; ++x){
			for(int y = 0; y <= maxNum; ++y){
				int z = sum - x - y;
				if(0 <= z && z <= maxNum){
					ans = ans + 1;
				}
			}
		}
		System.out.println(ans);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int maxNum = scan.nextInt(); maxNum scan.nextInt() scan.nextInt scan int sum = scan.nextInt(); sum scan.nextInt() scan.nextInt scan int ans = 0; ans 0 for(int x = 0; x <= maxNum; ++x){
			for(int y = 0; y <= maxNum; ++y){
				int z = sum - x - y;
				if(0 <= z && z <= maxNum){
					ans = ans + 1;
				}
			}
		} int x = 0; int x = 0; x 0 x <= maxNum x maxNum ++x ++x x {
			for(int y = 0; y <= maxNum; ++y){
				int z = sum - x - y;
				if(0 <= z && z <= maxNum){
					ans = ans + 1;
				}
			}
		} {
			for(int y = 0; y <= maxNum; ++y){
				int z = sum - x - y;
				if(0 <= z && z <= maxNum){
					ans = ans + 1;
				}
			}
		} for(int y = 0; y <= maxNum; ++y){
				int z = sum - x - y;
				if(0 <= z && z <= maxNum){
					ans = ans + 1;
				}
			} int y = 0; int y = 0; y 0 y <= maxNum y maxNum ++y ++y y {
				int z = sum - x - y;
				if(0 <= z && z <= maxNum){
					ans = ans + 1;
				}
			} {
				int z = sum - x - y;
				if(0 <= z && z <= maxNum){
					ans = ans + 1;
				}
			} int z = sum - x - y; z sum - x - y sum - x - y sum x y if(0 <= z && z <= maxNum){
					ans = ans + 1;
				} 0 <= z && z <= maxNum 0 <= z 0 z z <= maxNum z maxNum {
					ans = ans + 1;
				} ans = ans + 1 ans ans + 1 ans 1 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int maxNum = scan.nextInt();
		int sum = scan.nextInt();
		int ans = 0;
		
		for(int x = 0; x <= maxNum; ++x){
			for(int y = 0; y <= maxNum; ++y){
				int z = sum - x - y;
				if(0 <= z && z <= maxNum){
					ans = ans + 1;
				}
			}
		}
		System.out.println(ans);
	}
} public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int maxNum = scan.nextInt();
		int sum = scan.nextInt();
		int ans = 0;
		
		for(int x = 0; x <= maxNum; ++x){
			for(int y = 0; y <= maxNum; ++y){
				int z = sum - x - y;
				if(0 <= z && z <= maxNum){
					ans = ans + 1;
				}
			}
		}
		System.out.println(ans);
	}
} Main

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int maxNum = scan.nextInt();
		int sum = scan.nextInt();
		int ans = 0;
		
		for(int x = 0; x <= maxNum; ++x){
			for(int y = 0; y <= maxNum; ++y){
				int z = sum - x - y;
				if(0 <= z && z <= maxNum){
					ans = ans + 1;
				}
			}
		}
		System.out.println(ans);
	}
}
