import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int k = parseInt(sc.next());
		int s = parseInt(sc.next());
		sc.close();
		int cnt=0;
		for (i = 0; i <= k; i++) {
			for (j = 0; j <= k; j++) {
				if(0<=s-(i+j) && s-(i+j)<=k)cnt++;
			}
		}
		out.println(cnt);
	}
} import java.util.*; util.* java import java.io.PrintWriter; PrintWriter java.io import static java.lang.Integer.*; import static java.lang.Integer.*; import static java.lang.Integer.*; import static java.lang.Long.*; import static java.lang.Long.*; import static java.lang.Long.*; import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.System.*; import static java.lang.System.*; import static java.lang.System.*; public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int k = parseInt(sc.next());
		int s = parseInt(sc.next());
		sc.close();
		int cnt=0;
		for (i = 0; i <= k; i++) {
			for (j = 0; j <= k; j++) {
				if(0<=s-(i+j) && s-(i+j)<=k)cnt++;
			}
		}
		out.println(cnt);
	}
} Main public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int k = parseInt(sc.next());
		int s = parseInt(sc.next());
		sc.close();
		int cnt=0;
		for (i = 0; i <= k; i++) {
			for (j = 0; j <= k; j++) {
				if(0<=s-(i+j) && s-(i+j)<=k)cnt++;
			}
		}
		out.println(cnt);
	} main {
		int i,j;
		Scanner sc = new Scanner(in);
		int k = parseInt(sc.next());
		int s = parseInt(sc.next());
		sc.close();
		int cnt=0;
		for (i = 0; i <= k; i++) {
			for (j = 0; j <= k; j++) {
				if(0<=s-(i+j) && s-(i+j)<=k)cnt++;
			}
		}
		out.println(cnt);
	} int i i j; j Scanner sc = new Scanner(in); sc new Scanner(in) int k = parseInt(sc.next()); k parseInt(sc.next()) parseInt sc.next() sc.next sc int s = parseInt(sc.next()); s parseInt(sc.next()) parseInt sc.next() sc.next sc sc.close() sc.close sc int cnt=0; cnt 0 for (i = 0; i <= k; i++) {
			for (j = 0; j <= k; j++) {
				if(0<=s-(i+j) && s-(i+j)<=k)cnt++;
			}
		} i = 0; i = 0 i 0 i <= k i k i++ i++ i {
			for (j = 0; j <= k; j++) {
				if(0<=s-(i+j) && s-(i+j)<=k)cnt++;
			}
		} {
			for (j = 0; j <= k; j++) {
				if(0<=s-(i+j) && s-(i+j)<=k)cnt++;
			}
		} for (j = 0; j <= k; j++) {
				if(0<=s-(i+j) && s-(i+j)<=k)cnt++;
			} j = 0; j = 0 j 0 j <= k j k j++ j++ j {
				if(0<=s-(i+j) && s-(i+j)<=k)cnt++;
			} {
				if(0<=s-(i+j) && s-(i+j)<=k)cnt++;
			} if(0<=s-(i+j) && s-(i+j)<=k)cnt++; 0<=s-(i+j) && s-(i+j)<=k 0<=s-(i+j) 0 s-(i+j) s (i+j) i j s-(i+j)<=k s-(i+j) s (i+j) i j k cnt++ cnt out.println(cnt) out.println out cnt String[] args args public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int k = parseInt(sc.next());
		int s = parseInt(sc.next());
		sc.close();
		int cnt=0;
		for (i = 0; i <= k; i++) {
			for (j = 0; j <= k; j++) {
				if(0<=s-(i+j) && s-(i+j)<=k)cnt++;
			}
		}
		out.println(cnt);
	}
} public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int k = parseInt(sc.next());
		int s = parseInt(sc.next());
		sc.close();
		int cnt=0;
		for (i = 0; i <= k; i++) {
			for (j = 0; j <= k; j++) {
				if(0<=s-(i+j) && s-(i+j)<=k)cnt++;
			}
		}
		out.println(cnt);
	}
} Main
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int k = parseInt(sc.next());
		int s = parseInt(sc.next());
		sc.close();
		int cnt=0;
		for (i = 0; i <= k; i++) {
			for (j = 0; j <= k; j++) {
				if(0<=s-(i+j) && s-(i+j)<=k)cnt++;
			}
		}
		out.println(cnt);
	}
}
