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 ans = 0;
		
		int[] n = new int[k + 1];
		for (int i = 0; i <= k; i++) {
			n[i] = i;
		}
		
		
		// x, y , z <= k, x+y+z=s <=> x+y = s-z;
		for (int i = 0; i < n.length; i++) {
			int x = i;
			for (int j = 0; j < n.length; j++) {
				int y = j;
				int z = s - x - y;
				if (z>=0 && z<=k) {
					ans ++;
				}
			}
		}
		System.out.println(ans);
		
		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 ans = 0;
		
		int[] n = new int[k + 1];
		for (int i = 0; i <= k; i++) {
			n[i] = i;
		}
		
		
		// x, y , z <= k, x+y+z=s <=> x+y = s-z;
		for (int i = 0; i < n.length; i++) {
			int x = i;
			for (int j = 0; j < n.length; j++) {
				int y = j;
				int z = s - x - y;
				if (z>=0 && z<=k) {
					ans ++;
				}
			}
		}
		System.out.println(ans);
		
		scanner.close();
	}

} Main public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int k = scanner.nextInt();
		int s = scanner.nextInt();
		int ans = 0;
		
		int[] n = new int[k + 1];
		for (int i = 0; i <= k; i++) {
			n[i] = i;
		}
		
		
		// x, y , z <= k, x+y+z=s <=> x+y = s-z;
		for (int i = 0; i < n.length; i++) {
			int x = i;
			for (int j = 0; j < n.length; j++) {
				int y = j;
				int z = s - x - y;
				if (z>=0 && z<=k) {
					ans ++;
				}
			}
		}
		System.out.println(ans);
		
		scanner.close();
	} main {
		Scanner scanner = new Scanner(System.in);
		int k = scanner.nextInt();
		int s = scanner.nextInt();
		int ans = 0;
		
		int[] n = new int[k + 1];
		for (int i = 0; i <= k; i++) {
			n[i] = i;
		}
		
		
		// x, y , z <= k, x+y+z=s <=> x+y = s-z;
		for (int i = 0; i < n.length; i++) {
			int x = i;
			for (int j = 0; j < n.length; j++) {
				int y = j;
				int z = s - x - y;
				if (z>=0 && z<=k) {
					ans ++;
				}
			}
		}
		System.out.println(ans);
		
		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 ans = 0; ans 0 int[] n = new int[k + 1]; n new int[k + 1] k + 1 k 1 for (int i = 0; i <= k; i++) {
			n[i] = i;
		} int i = 0; int i = 0; i 0 i <= k i k i++ i++ i {
			n[i] = i;
		} {
			n[i] = i;
		} n[i] = i n[i] n i i for (int i = 0; i < n.length; i++) {
			int x = i;
			for (int j = 0; j < n.length; j++) {
				int y = j;
				int z = s - x - y;
				if (z>=0 && z<=k) {
					ans ++;
				}
			}
		} int i = 0; int i = 0; i 0 i < n.length i n.length n n.length i++ i++ i {
			int x = i;
			for (int j = 0; j < n.length; j++) {
				int y = j;
				int z = s - x - y;
				if (z>=0 && z<=k) {
					ans ++;
				}
			}
		} {
			int x = i;
			for (int j = 0; j < n.length; j++) {
				int y = j;
				int z = s - x - y;
				if (z>=0 && z<=k) {
					ans ++;
				}
			}
		} int x = i; x i for (int j = 0; j < n.length; j++) {
				int y = j;
				int z = s - x - y;
				if (z>=0 && z<=k) {
					ans ++;
				}
			} int j = 0; int j = 0; j 0 j < n.length j n.length n n.length j++ j++ j {
				int y = j;
				int z = s - x - y;
				if (z>=0 && z<=k) {
					ans ++;
				}
			} {
				int y = j;
				int z = s - x - y;
				if (z>=0 && z<=k) {
					ans ++;
				}
			} int y = j; y j int z = s - x - y; z s - x - y s - x - y s x y if (z>=0 && z<=k) {
					ans ++;
				} z>=0 && z<=k z>=0 z 0 z<=k z k {
					ans ++;
				} ans ++ ans System.out.println(ans) System.out.println System.out System System.out ans 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 ans = 0;
		
		int[] n = new int[k + 1];
		for (int i = 0; i <= k; i++) {
			n[i] = i;
		}
		
		
		// x, y , z <= k, x+y+z=s <=> x+y = s-z;
		for (int i = 0; i < n.length; i++) {
			int x = i;
			for (int j = 0; j < n.length; j++) {
				int y = j;
				int z = s - x - y;
				if (z>=0 && z<=k) {
					ans ++;
				}
			}
		}
		System.out.println(ans);
		
		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 ans = 0;
		
		int[] n = new int[k + 1];
		for (int i = 0; i <= k; i++) {
			n[i] = i;
		}
		
		
		// x, y , z <= k, x+y+z=s <=> x+y = s-z;
		for (int i = 0; i < n.length; i++) {
			int x = i;
			for (int j = 0; j < n.length; j++) {
				int y = j;
				int z = s - x - y;
				if (z>=0 && z<=k) {
					ans ++;
				}
			}
		}
		System.out.println(ans);
		
		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 ans = 0;
		
		int[] n = new int[k + 1];
		for (int i = 0; i <= k; i++) {
			n[i] = i;
		}
		
		
		// x, y , z <= k, x+y+z=s <=> x+y = s-z;
		for (int i = 0; i < n.length; i++) {
			int x = i;
			for (int j = 0; j < n.length; j++) {
				int y = j;
				int z = s - x - y;
				if (z>=0 && z<=k) {
					ans ++;
				}
			}
		}
		System.out.println(ans);
		
		scanner.close();
	}

}