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 cnt = 0;
		for (int x = 0; x <= k && x <= s; x++) {
			for (int y = 0; y <= k && x + y <= s; y++) {
				if (s - x - y <= k) cnt++;
			}
		}
		
		System.out.println(cnt);
		
		sc.close();
	}
	
}

 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 cnt = 0;
		for (int x = 0; x <= k && x <= s; x++) {
			for (int y = 0; y <= k && x + y <= s; y++) {
				if (s - x - y <= k) cnt++;
			}
		}
		
		System.out.println(cnt);
		
		sc.close();
	}
	
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		
		int cnt = 0;
		for (int x = 0; x <= k && x <= s; x++) {
			for (int y = 0; y <= k && x + y <= s; y++) {
				if (s - x - y <= k) cnt++;
			}
		}
		
		System.out.println(cnt);
		
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		
		int cnt = 0;
		for (int x = 0; x <= k && x <= s; x++) {
			for (int y = 0; y <= k && x + y <= s; y++) {
				if (s - x - y <= k) cnt++;
			}
		}
		
		System.out.println(cnt);
		
		sc.close();
	} 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 cnt = 0; cnt 0 for (int x = 0; x <= k && x <= s; x++) {
			for (int y = 0; y <= k && x + y <= s; y++) {
				if (s - x - y <= k) cnt++;
			}
		} 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 && x + y <= s; y++) {
				if (s - x - y <= k) cnt++;
			}
		} {
			for (int y = 0; y <= k && x + y <= s; y++) {
				if (s - x - y <= k) cnt++;
			}
		} for (int y = 0; y <= k && x + y <= s; y++) {
				if (s - x - y <= k) cnt++;
			} int y = 0; int y = 0; y 0 y <= k && x + y <= s y <= k y k x + y <= s x + y x y s y++ y++ y {
				if (s - x - y <= k) cnt++;
			} {
				if (s - x - y <= k) cnt++;
			} if (s - x - y <= k) cnt++; s - x - y <= k s - x - y s - x - y s x y k cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt sc.close() sc.close sc 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 cnt = 0;
		for (int x = 0; x <= k && x <= s; x++) {
			for (int y = 0; y <= k && x + y <= s; y++) {
				if (s - x - y <= k) cnt++;
			}
		}
		
		System.out.println(cnt);
		
		sc.close();
	}
	
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		
		int cnt = 0;
		for (int x = 0; x <= k && x <= s; x++) {
			for (int y = 0; y <= k && x + y <= s; y++) {
				if (s - x - y <= k) cnt++;
			}
		}
		
		System.out.println(cnt);
		
		sc.close();
	}
	
} 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 cnt = 0;
		for (int x = 0; x <= k && x <= s; x++) {
			for (int y = 0; y <= k && x + y <= s; y++) {
				if (s - x - y <= k) cnt++;
			}
		}
		
		System.out.println(cnt);
		
		sc.close();
	}
	
}


