import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int  k = scanner.nextInt();
		int  s=scanner.nextInt();


		int result=0;

		for(int x=0;x<=k;x++) {

			for(int y=0;y<=k;y++) {

				boolean isMacth= k>=s-(x+y) && s-(x+y)>=0;

				if(isMacth) {
					result++;
				}

			}

		}

		System.out.println(result);


		scanner.close();

	}




} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int  k = scanner.nextInt();
		int  s=scanner.nextInt();


		int result=0;

		for(int x=0;x<=k;x++) {

			for(int y=0;y<=k;y++) {

				boolean isMacth= k>=s-(x+y) && s-(x+y)>=0;

				if(isMacth) {
					result++;
				}

			}

		}

		System.out.println(result);


		scanner.close();

	}




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

		Scanner scanner = new Scanner(System.in);

		int  k = scanner.nextInt();
		int  s=scanner.nextInt();


		int result=0;

		for(int x=0;x<=k;x++) {

			for(int y=0;y<=k;y++) {

				boolean isMacth= k>=s-(x+y) && s-(x+y)>=0;

				if(isMacth) {
					result++;
				}

			}

		}

		System.out.println(result);


		scanner.close();

	} main {

		Scanner scanner = new Scanner(System.in);

		int  k = scanner.nextInt();
		int  s=scanner.nextInt();


		int result=0;

		for(int x=0;x<=k;x++) {

			for(int y=0;y<=k;y++) {

				boolean isMacth= k>=s-(x+y) && s-(x+y)>=0;

				if(isMacth) {
					result++;
				}

			}

		}

		System.out.println(result);


		scanner.close();

	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int  k = scanner.nextInt(); k scanner.nextInt() scanner.nextInt scanner int  s=scanner.nextInt(); s scanner.nextInt() scanner.nextInt scanner int result=0; result 0 for(int x=0;x<=k;x++) {

			for(int y=0;y<=k;y++) {

				boolean isMacth= k>=s-(x+y) && s-(x+y)>=0;

				if(isMacth) {
					result++;
				}

			}

		} int x=0; int x=0; x 0 x<=k x k x++ x++ x {

			for(int y=0;y<=k;y++) {

				boolean isMacth= k>=s-(x+y) && s-(x+y)>=0;

				if(isMacth) {
					result++;
				}

			}

		} {

			for(int y=0;y<=k;y++) {

				boolean isMacth= k>=s-(x+y) && s-(x+y)>=0;

				if(isMacth) {
					result++;
				}

			}

		} for(int y=0;y<=k;y++) {

				boolean isMacth= k>=s-(x+y) && s-(x+y)>=0;

				if(isMacth) {
					result++;
				}

			} int y=0; int y=0; y 0 y<=k y k y++ y++ y {

				boolean isMacth= k>=s-(x+y) && s-(x+y)>=0;

				if(isMacth) {
					result++;
				}

			} {

				boolean isMacth= k>=s-(x+y) && s-(x+y)>=0;

				if(isMacth) {
					result++;
				}

			} boolean isMacth= k>=s-(x+y) && s-(x+y)>=0; isMacth k>=s-(x+y) && s-(x+y)>=0 k>=s-(x+y) k s-(x+y) s (x+y) x y s-(x+y)>=0 s-(x+y) s (x+y) x y 0 if(isMacth) {
					result++;
				} isMacth {
					result++;
				} result++ result System.out.println(result) System.out.println System.out System System.out result scanner.close() scanner.close scanner String[] args args public class Main {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int  k = scanner.nextInt();
		int  s=scanner.nextInt();


		int result=0;

		for(int x=0;x<=k;x++) {

			for(int y=0;y<=k;y++) {

				boolean isMacth= k>=s-(x+y) && s-(x+y)>=0;

				if(isMacth) {
					result++;
				}

			}

		}

		System.out.println(result);


		scanner.close();

	}




} public class Main {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int  k = scanner.nextInt();
		int  s=scanner.nextInt();


		int result=0;

		for(int x=0;x<=k;x++) {

			for(int y=0;y<=k;y++) {

				boolean isMacth= k>=s-(x+y) && s-(x+y)>=0;

				if(isMacth) {
					result++;
				}

			}

		}

		System.out.println(result);


		scanner.close();

	}




} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int  k = scanner.nextInt();
		int  s=scanner.nextInt();


		int result=0;

		for(int x=0;x<=k;x++) {

			for(int y=0;y<=k;y++) {

				boolean isMacth= k>=s-(x+y) && s-(x+y)>=0;

				if(isMacth) {
					result++;
				}

			}

		}

		System.out.println(result);


		scanner.close();

	}




}
