import java.io.*;
class Main {
	static StreamTokenizer st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
	static int nextInt() throws IOException {
		st.nextToken();
		return (int)st.nval;
	}
	public static void main(String[] args) throws IOException {
		PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
		int k = nextInt(), s = nextInt(), ans = 0;
		for(int x=0;x<=k && x<=s;++x) {
			for(int y=0;y<=k && y+x<=s;++y) {
				if(s-x-y<=k) ++ans;
			}
		}
		pw.print(ans);
		pw.print('\n');
		pw.flush();
	}
} import java.io.*; io.* java class Main {
	static StreamTokenizer st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
	static int nextInt() throws IOException {
		st.nextToken();
		return (int)st.nval;
	}
	public static void main(String[] args) throws IOException {
		PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
		int k = nextInt(), s = nextInt(), ans = 0;
		for(int x=0;x<=k && x<=s;++x) {
			for(int y=0;y<=k && y+x<=s;++y) {
				if(s-x-y<=k) ++ans;
			}
		}
		pw.print(ans);
		pw.print('\n');
		pw.flush();
	}
} Main static StreamTokenizer st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); st new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))) static int nextInt() throws IOException {
		st.nextToken();
		return (int)st.nval;
	} nextInt {
		st.nextToken();
		return (int)st.nval;
	} st.nextToken() st.nextToken st return (int)st.nval; (int)st.nval st st.nval public static void main(String[] args) throws IOException {
		PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
		int k = nextInt(), s = nextInt(), ans = 0;
		for(int x=0;x<=k && x<=s;++x) {
			for(int y=0;y<=k && y+x<=s;++y) {
				if(s-x-y<=k) ++ans;
			}
		}
		pw.print(ans);
		pw.print('\n');
		pw.flush();
	} main {
		PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
		int k = nextInt(), s = nextInt(), ans = 0;
		for(int x=0;x<=k && x<=s;++x) {
			for(int y=0;y<=k && y+x<=s;++y) {
				if(s-x-y<=k) ++ans;
			}
		}
		pw.print(ans);
		pw.print('\n');
		pw.flush();
	} PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out)); pw new PrintWriter(new OutputStreamWriter(System.out)) int k = nextInt() k nextInt() nextInt s = nextInt() s nextInt() nextInt ans = 0; ans 0 for(int x=0;x<=k && x<=s;++x) {
			for(int y=0;y<=k && y+x<=s;++y) {
				if(s-x-y<=k) ++ans;
			}
		} int x=0; int x=0; x 0 x<=k && x<=s x<=k x k x<=s x s ++x ++x x {
			for(int y=0;y<=k && y+x<=s;++y) {
				if(s-x-y<=k) ++ans;
			}
		} {
			for(int y=0;y<=k && y+x<=s;++y) {
				if(s-x-y<=k) ++ans;
			}
		} for(int y=0;y<=k && y+x<=s;++y) {
				if(s-x-y<=k) ++ans;
			} int y=0; int y=0; y 0 y<=k && y+x<=s y<=k y k y+x<=s y+x y x s ++y ++y y {
				if(s-x-y<=k) ++ans;
			} {
				if(s-x-y<=k) ++ans;
			} if(s-x-y<=k) ++ans; s-x-y<=k s-x-y s-x-y s x y k ++ans ans pw.print(ans) pw.print pw ans pw.print('\n') pw.print pw '\n' pw.flush() pw.flush pw String[] args args
import java.io.*;
class Main {
	static StreamTokenizer st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
	static int nextInt() throws IOException {
		st.nextToken();
		return (int)st.nval;
	}
	public static void main(String[] args) throws IOException {
		PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
		int k = nextInt(), s = nextInt(), ans = 0;
		for(int x=0;x<=k && x<=s;++x) {
			for(int y=0;y<=k && y+x<=s;++y) {
				if(s-x-y<=k) ++ans;
			}
		}
		pw.print(ans);
		pw.print('\n');
		pw.flush();
	}
}