import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int ans=0;
		for(int i=0;i!=a+1;i++) {
			for(int j=0;j!=a+1;j++) {
				if(b-i-j>=0&&b-i-j<=a) {
					ans++;
				}
			}
		}
		System.out.println(ans);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int ans=0;
		for(int i=0;i!=a+1;i++) {
			for(int j=0;j!=a+1;j++) {
				if(b-i-j>=0&&b-i-j<=a) {
					ans++;
				}
			}
		}
		System.out.println(ans);
	}
} Main public static void main(String[] args) throws Exception{
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int ans=0;
		for(int i=0;i!=a+1;i++) {
			for(int j=0;j!=a+1;j++) {
				if(b-i-j>=0&&b-i-j<=a) {
					ans++;
				}
			}
		}
		System.out.println(ans);
	} main {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int ans=0;
		for(int i=0;i!=a+1;i++) {
			for(int j=0;j!=a+1;j++) {
				if(b-i-j>=0&&b-i-j<=a) {
					ans++;
				}
			}
		}
		System.out.println(ans);
	} Scanner scan=new Scanner(System.in); scan new Scanner(System.in) int a=scan.nextInt(); a scan.nextInt() scan.nextInt scan int b=scan.nextInt(); b scan.nextInt() scan.nextInt scan int ans=0; ans 0 for(int i=0;i!=a+1;i++) {
			for(int j=0;j!=a+1;j++) {
				if(b-i-j>=0&&b-i-j<=a) {
					ans++;
				}
			}
		} int i=0; int i=0; i 0 i!=a+1 i a+1 a 1 i++ i++ i {
			for(int j=0;j!=a+1;j++) {
				if(b-i-j>=0&&b-i-j<=a) {
					ans++;
				}
			}
		} {
			for(int j=0;j!=a+1;j++) {
				if(b-i-j>=0&&b-i-j<=a) {
					ans++;
				}
			}
		} for(int j=0;j!=a+1;j++) {
				if(b-i-j>=0&&b-i-j<=a) {
					ans++;
				}
			} int j=0; int j=0; j 0 j!=a+1 j a+1 a 1 j++ j++ j {
				if(b-i-j>=0&&b-i-j<=a) {
					ans++;
				}
			} {
				if(b-i-j>=0&&b-i-j<=a) {
					ans++;
				}
			} if(b-i-j>=0&&b-i-j<=a) {
					ans++;
				} b-i-j>=0&&b-i-j<=a b-i-j>=0 b-i-j b-i-j b i j 0 b-i-j<=a b-i-j b-i-j b i j a {
					ans++;
				} ans++ ans 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) throws Exception{
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int ans=0;
		for(int i=0;i!=a+1;i++) {
			for(int j=0;j!=a+1;j++) {
				if(b-i-j>=0&&b-i-j<=a) {
					ans++;
				}
			}
		}
		System.out.println(ans);
	}
} public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int ans=0;
		for(int i=0;i!=a+1;i++) {
			for(int j=0;j!=a+1;j++) {
				if(b-i-j>=0&&b-i-j<=a) {
					ans++;
				}
			}
		}
		System.out.println(ans);
	}
} Main
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int ans=0;
		for(int i=0;i!=a+1;i++) {
			for(int j=0;j!=a+1;j++) {
				if(b-i-j>=0&&b-i-j<=a) {
					ans++;
				}
			}
		}
		System.out.println(ans);
	}
}
