import java.util.*;
public class Main {
//3つの整数の合計
	public static void main(String[] args) {
		int k, s, l, cnt = 0;
		Scanner sc = new Scanner(System.in);
		k = sc.nextInt();
		s = sc.nextInt();
		for(int i = 0; i <= k; i++)
		{
			for(int j = 0; j <= k; j++)
			{
				l = s - (i + j);
				if(l >= 0 && l <= k) cnt++;
			}
		}
		System.out.println(cnt);
	}

} import java.util.*; util.* java public class Main {
//3つの整数の合計
	public static void main(String[] args) {
		int k, s, l, cnt = 0;
		Scanner sc = new Scanner(System.in);
		k = sc.nextInt();
		s = sc.nextInt();
		for(int i = 0; i <= k; i++)
		{
			for(int j = 0; j <= k; j++)
			{
				l = s - (i + j);
				if(l >= 0 && l <= k) cnt++;
			}
		}
		System.out.println(cnt);
	}

} Main //3つの整数の合計
	public static void main(String[] args) {
		int k, s, l, cnt = 0;
		Scanner sc = new Scanner(System.in);
		k = sc.nextInt();
		s = sc.nextInt();
		for(int i = 0; i <= k; i++)
		{
			for(int j = 0; j <= k; j++)
			{
				l = s - (i + j);
				if(l >= 0 && l <= k) cnt++;
			}
		}
		System.out.println(cnt);
	} main {
		int k, s, l, cnt = 0;
		Scanner sc = new Scanner(System.in);
		k = sc.nextInt();
		s = sc.nextInt();
		for(int i = 0; i <= k; i++)
		{
			for(int j = 0; j <= k; j++)
			{
				l = s - (i + j);
				if(l >= 0 && l <= k) cnt++;
			}
		}
		System.out.println(cnt);
	} int k k s s l l cnt = 0; cnt 0 Scanner sc = new Scanner(System.in); sc new Scanner(System.in) k = sc.nextInt() k sc.nextInt() sc.nextInt sc s = sc.nextInt() s sc.nextInt() sc.nextInt sc for(int i = 0; i <= k; i++)
		{
			for(int j = 0; j <= k; j++)
			{
				l = s - (i + j);
				if(l >= 0 && l <= k) cnt++;
			}
		} int i = 0; int i = 0; i 0 i <= k i k i++ i++ i {
			for(int j = 0; j <= k; j++)
			{
				l = s - (i + j);
				if(l >= 0 && l <= k) cnt++;
			}
		} {
			for(int j = 0; j <= k; j++)
			{
				l = s - (i + j);
				if(l >= 0 && l <= k) cnt++;
			}
		} for(int j = 0; j <= k; j++)
			{
				l = s - (i + j);
				if(l >= 0 && l <= k) cnt++;
			} int j = 0; int j = 0; j 0 j <= k j k j++ j++ j {
				l = s - (i + j);
				if(l >= 0 && l <= k) cnt++;
			} {
				l = s - (i + j);
				if(l >= 0 && l <= k) cnt++;
			} l = s - (i + j) l s - (i + j) s (i + j) i j if(l >= 0 && l <= k) cnt++; l >= 0 && l <= k l >= 0 l 0 l <= k l k cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {
//3つの整数の合計
	public static void main(String[] args) {
		int k, s, l, cnt = 0;
		Scanner sc = new Scanner(System.in);
		k = sc.nextInt();
		s = sc.nextInt();
		for(int i = 0; i <= k; i++)
		{
			for(int j = 0; j <= k; j++)
			{
				l = s - (i + j);
				if(l >= 0 && l <= k) cnt++;
			}
		}
		System.out.println(cnt);
	}

} public class Main {
//3つの整数の合計
	public static void main(String[] args) {
		int k, s, l, cnt = 0;
		Scanner sc = new Scanner(System.in);
		k = sc.nextInt();
		s = sc.nextInt();
		for(int i = 0; i <= k; i++)
		{
			for(int j = 0; j <= k; j++)
			{
				l = s - (i + j);
				if(l >= 0 && l <= k) cnt++;
			}
		}
		System.out.println(cnt);
	}

} Main
import java.util.*;
public class Main {
//3つの整数の合計
	public static void main(String[] args) {
		int k, s, l, cnt = 0;
		Scanner sc = new Scanner(System.in);
		k = sc.nextInt();
		s = sc.nextInt();
		for(int i = 0; i <= k; i++)
		{
			for(int j = 0; j <= k; j++)
			{
				l = s - (i + j);
				if(l >= 0 && l <= k) cnt++;
			}
		}
		System.out.println(cnt);
	}

}