import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		int count =0;
		int start,end;
		if (S<K) {
			end = S;
		} else {
			end = K;
		}
		if (S-2*K>0) {
			start = S-2*K;
		} else {
			start =0;
		}
		for (int x=start;x<=end;x++) {
			int temp = S-x;
			if (temp >K) {
				count += 2*K-temp+1;
			} else {
				count +=temp+1;
			}
		}
		System.out.println(count);
	}
} 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();
		int S = sc.nextInt();
		int count =0;
		int start,end;
		if (S<K) {
			end = S;
		} else {
			end = K;
		}
		if (S-2*K>0) {
			start = S-2*K;
		} else {
			start =0;
		}
		for (int x=start;x<=end;x++) {
			int temp = S-x;
			if (temp >K) {
				count += 2*K-temp+1;
			} else {
				count +=temp+1;
			}
		}
		System.out.println(count);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		int count =0;
		int start,end;
		if (S<K) {
			end = S;
		} else {
			end = K;
		}
		if (S-2*K>0) {
			start = S-2*K;
		} else {
			start =0;
		}
		for (int x=start;x<=end;x++) {
			int temp = S-x;
			if (temp >K) {
				count += 2*K-temp+1;
			} else {
				count +=temp+1;
			}
		}
		System.out.println(count);
	} main {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		int count =0;
		int start,end;
		if (S<K) {
			end = S;
		} else {
			end = K;
		}
		if (S-2*K>0) {
			start = S-2*K;
		} else {
			start =0;
		}
		for (int x=start;x<=end;x++) {
			int temp = S-x;
			if (temp >K) {
				count += 2*K-temp+1;
			} else {
				count +=temp+1;
			}
		}
		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 int S = sc.nextInt(); S sc.nextInt() sc.nextInt sc int count =0; count 0 int start start end; end if (S<K) {
			end = S;
		} else {
			end = K;
		} S<K S K {
			end = S;
		} end = S end S {
			end = K;
		} end = K end K if (S-2*K>0) {
			start = S-2*K;
		} else {
			start =0;
		} S-2*K>0 S-2*K S 2*K 2 K 0 {
			start = S-2*K;
		} start = S-2*K start S-2*K S 2*K 2 K {
			start =0;
		} start =0 start 0 for (int x=start;x<=end;x++) {
			int temp = S-x;
			if (temp >K) {
				count += 2*K-temp+1;
			} else {
				count +=temp+1;
			}
		} int x=start; int x=start; x start x<=end x end x++ x++ x {
			int temp = S-x;
			if (temp >K) {
				count += 2*K-temp+1;
			} else {
				count +=temp+1;
			}
		} {
			int temp = S-x;
			if (temp >K) {
				count += 2*K-temp+1;
			} else {
				count +=temp+1;
			}
		} int temp = S-x; temp S-x S x if (temp >K) {
				count += 2*K-temp+1;
			} else {
				count +=temp+1;
			} temp >K temp K {
				count += 2*K-temp+1;
			} count += 2*K-temp+1 count 2*K-temp+1 2*K-temp 2*K 2 K temp 1 {
				count +=temp+1;
			} count +=temp+1 count temp+1 temp 1 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) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		int count =0;
		int start,end;
		if (S<K) {
			end = S;
		} else {
			end = K;
		}
		if (S-2*K>0) {
			start = S-2*K;
		} else {
			start =0;
		}
		for (int x=start;x<=end;x++) {
			int temp = S-x;
			if (temp >K) {
				count += 2*K-temp+1;
			} else {
				count +=temp+1;
			}
		}
		System.out.println(count);
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		int count =0;
		int start,end;
		if (S<K) {
			end = S;
		} else {
			end = K;
		}
		if (S-2*K>0) {
			start = S-2*K;
		} else {
			start =0;
		}
		for (int x=start;x<=end;x++) {
			int temp = S-x;
			if (temp >K) {
				count += 2*K-temp+1;
			} else {
				count +=temp+1;
			}
		}
		System.out.println(count);
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		int count =0;
		int start,end;
		if (S<K) {
			end = S;
		} else {
			end = K;
		}
		if (S-2*K>0) {
			start = S-2*K;
		} else {
			start =0;
		}
		for (int x=start;x<=end;x++) {
			int temp = S-x;
			if (temp >K) {
				count += 2*K-temp+1;
			} else {
				count +=temp+1;
			}
		}
		System.out.println(count);
	}
}