import java.util.*;
// warm-up
// Even better without extra space with a simple branch. Thanks to Editorial. 
// Technically no need for another loop and a map to cross check.
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt(), s = sc.nextInt(), t=0;
		for (int i=0; i<=K; i++) {
			for (int j=0; j<=K; j++) {
				int z = s-i-j;
				if (z>=0 && z<=K) t++;
			}
		}
		System.out.println(t);
		sc.close();			
	}

	public static void main(String args[]) {
		solve();
	}

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

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt(), s = sc.nextInt(), t=0;
		for (int i=0; i<=K; i++) {
			for (int j=0; j<=K; j++) {
				int z = s-i-j;
				if (z>=0 && z<=K) t++;
			}
		}
		System.out.println(t);
		sc.close();			
	}

	public static void main(String args[]) {
		solve();
	}

} Main static void solve() {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt(), s = sc.nextInt(), t=0;
		for (int i=0; i<=K; i++) {
			for (int j=0; j<=K; j++) {
				int z = s-i-j;
				if (z>=0 && z<=K) t++;
			}
		}
		System.out.println(t);
		sc.close();			
	} solve {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt(), s = sc.nextInt(), t=0;
		for (int i=0; i<=K; i++) {
			for (int j=0; j<=K; j++) {
				int z = s-i-j;
				if (z>=0 && z<=K) t++;
			}
		}
		System.out.println(t);
		sc.close();			
	} 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 t=0; t 0 for (int i=0; i<=K; i++) {
			for (int j=0; j<=K; j++) {
				int z = s-i-j;
				if (z>=0 && z<=K) t++;
			}
		} int i=0; int i=0; i 0 i<=K i K i++ i++ i {
			for (int j=0; j<=K; j++) {
				int z = s-i-j;
				if (z>=0 && z<=K) t++;
			}
		} {
			for (int j=0; j<=K; j++) {
				int z = s-i-j;
				if (z>=0 && z<=K) t++;
			}
		} for (int j=0; j<=K; j++) {
				int z = s-i-j;
				if (z>=0 && z<=K) t++;
			} int j=0; int j=0; j 0 j<=K j K j++ j++ j {
				int z = s-i-j;
				if (z>=0 && z<=K) t++;
			} {
				int z = s-i-j;
				if (z>=0 && z<=K) t++;
			} int z = s-i-j; z s-i-j s-i-j s i j if (z>=0 && z<=K) t++; z>=0 && z<=K z>=0 z 0 z<=K z K t++ t System.out.println(t) System.out.println System.out System System.out t sc.close() sc.close sc public static void main(String args[]) {
		solve();
	} main {
		solve();
	} solve() solve String args[] args public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt(), s = sc.nextInt(), t=0;
		for (int i=0; i<=K; i++) {
			for (int j=0; j<=K; j++) {
				int z = s-i-j;
				if (z>=0 && z<=K) t++;
			}
		}
		System.out.println(t);
		sc.close();			
	}

	public static void main(String args[]) {
		solve();
	}

} public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt(), s = sc.nextInt(), t=0;
		for (int i=0; i<=K; i++) {
			for (int j=0; j<=K; j++) {
				int z = s-i-j;
				if (z>=0 && z<=K) t++;
			}
		}
		System.out.println(t);
		sc.close();			
	}

	public static void main(String args[]) {
		solve();
	}

} Main
import java.util.*;
// warm-up
// Even better without extra space with a simple branch. Thanks to Editorial. 
// Technically no need for another loop and a map to cross check.
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt(), s = sc.nextInt(), t=0;
		for (int i=0; i<=K; i++) {
			for (int j=0; j<=K; j++) {
				int z = s-i-j;
				if (z>=0 && z<=K) t++;
			}
		}
		System.out.println(t);
		sc.close();			
	}

	public static void main(String args[]) {
		solve();
	}

}