import java.util.Scanner;

public class Main {

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


	}
	public static int sample(int n) {
		return n;
	}

} import java.util.Scanner; Scanner java.util public class Main {

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


	}
	public static int sample(int n) {
		return n;
	}

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


	} main {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt(),S=sc.nextInt();
		int count = 0;
		for(int i=0;i<=K;i++) {
			for(int j=0;j<=K;j++) {
				int l=S-i-j;
				//System.out.println(l);
				if(l>=0 && l<=K && i+j+l==S) {
					count++;
				}
			}
		}
		System.out.println(count);


	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int K = sc.nextInt() K sc.nextInt() sc.nextInt sc S=sc.nextInt(); S sc.nextInt() sc.nextInt sc int count = 0; count 0 for(int i=0;i<=K;i++) {
			for(int j=0;j<=K;j++) {
				int l=S-i-j;
				//System.out.println(l);
				if(l>=0 && l<=K && i+j+l==S) {
					count++;
				}
			}
		} int i=0; int i=0; i 0 i<=K i K i++ i++ i {
			for(int j=0;j<=K;j++) {
				int l=S-i-j;
				//System.out.println(l);
				if(l>=0 && l<=K && i+j+l==S) {
					count++;
				}
			}
		} {
			for(int j=0;j<=K;j++) {
				int l=S-i-j;
				//System.out.println(l);
				if(l>=0 && l<=K && i+j+l==S) {
					count++;
				}
			}
		} for(int j=0;j<=K;j++) {
				int l=S-i-j;
				//System.out.println(l);
				if(l>=0 && l<=K && i+j+l==S) {
					count++;
				}
			} int j=0; int j=0; j 0 j<=K j K j++ j++ j {
				int l=S-i-j;
				//System.out.println(l);
				if(l>=0 && l<=K && i+j+l==S) {
					count++;
				}
			} {
				int l=S-i-j;
				//System.out.println(l);
				if(l>=0 && l<=K && i+j+l==S) {
					count++;
				}
			} int l=S-i-j; l S-i-j S-i-j S i j if(l>=0 && l<=K && i+j+l==S) {
					count++;
				} l>=0 && l<=K && i+j+l==S l>=0 && l<=K && i+j+l==S l>=0 l 0 l<=K l K i+j+l==S i+j+l i+j+l i j l S {
					count++;
				} count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public static int sample(int n) {
		return n;
	} sample {
		return n;
	} return n; n int n n public class Main {

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


	}
	public static int sample(int n) {
		return n;
	}

} public class Main {

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


	}
	public static int sample(int n) {
		return n;
	}

} Main
import java.util.Scanner;

public class Main {

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


	}
	public static int sample(int n) {
		return n;
	}

}
