import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		atcode();
	}

	public static void atcode() {
		String[] info=new Scanner(System.in).nextLine().split(" ");
		Integer max=Integer.valueOf(info[0]);
		Integer sum=Integer.valueOf(info[1]);
		int count=0;
		for(int x=0;x<=max;x++) {
			for(int y=0;y<=max;y++) {
				int z=sum-x-y;
				if(z>=0&&z<=max)count++;
			}
		}
		System.out.println(count);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		atcode();
	}

	public static void atcode() {
		String[] info=new Scanner(System.in).nextLine().split(" ");
		Integer max=Integer.valueOf(info[0]);
		Integer sum=Integer.valueOf(info[1]);
		int count=0;
		for(int x=0;x<=max;x++) {
			for(int y=0;y<=max;y++) {
				int z=sum-x-y;
				if(z>=0&&z<=max)count++;
			}
		}
		System.out.println(count);
	}
} Main public static void main(String[] args) {
		atcode();
	} main {
		atcode();
	} atcode() atcode String[] args args public static void atcode() {
		String[] info=new Scanner(System.in).nextLine().split(" ");
		Integer max=Integer.valueOf(info[0]);
		Integer sum=Integer.valueOf(info[1]);
		int count=0;
		for(int x=0;x<=max;x++) {
			for(int y=0;y<=max;y++) {
				int z=sum-x-y;
				if(z>=0&&z<=max)count++;
			}
		}
		System.out.println(count);
	} atcode {
		String[] info=new Scanner(System.in).nextLine().split(" ");
		Integer max=Integer.valueOf(info[0]);
		Integer sum=Integer.valueOf(info[1]);
		int count=0;
		for(int x=0;x<=max;x++) {
			for(int y=0;y<=max;y++) {
				int z=sum-x-y;
				if(z>=0&&z<=max)count++;
			}
		}
		System.out.println(count);
	} String[] info=new Scanner(System.in).nextLine().split(" "); info new Scanner(System.in).nextLine().split(" ") new Scanner(System.in).nextLine().split new Scanner(System.in).nextLine() new Scanner(System.in).nextLine new Scanner(System.in) " " Integer max=Integer.valueOf(info[0]); max Integer.valueOf(info[0]) Integer.valueOf Integer info[0] info 0 Integer sum=Integer.valueOf(info[1]); sum Integer.valueOf(info[1]) Integer.valueOf Integer info[1] info 1 int count=0; count 0 for(int x=0;x<=max;x++) {
			for(int y=0;y<=max;y++) {
				int z=sum-x-y;
				if(z>=0&&z<=max)count++;
			}
		} int x=0; int x=0; x 0 x<=max x max x++ x++ x {
			for(int y=0;y<=max;y++) {
				int z=sum-x-y;
				if(z>=0&&z<=max)count++;
			}
		} {
			for(int y=0;y<=max;y++) {
				int z=sum-x-y;
				if(z>=0&&z<=max)count++;
			}
		} for(int y=0;y<=max;y++) {
				int z=sum-x-y;
				if(z>=0&&z<=max)count++;
			} int y=0; int y=0; y 0 y<=max y max y++ y++ y {
				int z=sum-x-y;
				if(z>=0&&z<=max)count++;
			} {
				int z=sum-x-y;
				if(z>=0&&z<=max)count++;
			} int z=sum-x-y; z sum-x-y sum-x-y sum x y if(z>=0&&z<=max)count++; z>=0&&z<=max z>=0 z 0 z<=max z max count++ count System.out.println(count) System.out.println System.out System System.out count public class Main {
	public static void main(String[] args) {
		atcode();
	}

	public static void atcode() {
		String[] info=new Scanner(System.in).nextLine().split(" ");
		Integer max=Integer.valueOf(info[0]);
		Integer sum=Integer.valueOf(info[1]);
		int count=0;
		for(int x=0;x<=max;x++) {
			for(int y=0;y<=max;y++) {
				int z=sum-x-y;
				if(z>=0&&z<=max)count++;
			}
		}
		System.out.println(count);
	}
} public class Main {
	public static void main(String[] args) {
		atcode();
	}

	public static void atcode() {
		String[] info=new Scanner(System.in).nextLine().split(" ");
		Integer max=Integer.valueOf(info[0]);
		Integer sum=Integer.valueOf(info[1]);
		int count=0;
		for(int x=0;x<=max;x++) {
			for(int y=0;y<=max;y++) {
				int z=sum-x-y;
				if(z>=0&&z<=max)count++;
			}
		}
		System.out.println(count);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		atcode();
	}

	public static void atcode() {
		String[] info=new Scanner(System.in).nextLine().split(" ");
		Integer max=Integer.valueOf(info[0]);
		Integer sum=Integer.valueOf(info[1]);
		int count=0;
		for(int x=0;x<=max;x++) {
			for(int y=0;y<=max;y++) {
				int z=sum-x-y;
				if(z>=0&&z<=max)count++;
			}
		}
		System.out.println(count);
	}
}
