import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = Integer.parseInt(sc.next());
		int S = Integer.parseInt(sc.next());
		sc.close();
		int cnt = 0;
		for(int X = 0;X <= K;X++) {
			for(int Y = 0;Y <= K;Y++) {
				if(S - X - Y <= K && S - X - Y >= 0) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = Integer.parseInt(sc.next());
		int S = Integer.parseInt(sc.next());
		sc.close();
		int cnt = 0;
		for(int X = 0;X <= K;X++) {
			for(int Y = 0;Y <= K;Y++) {
				if(S - X - Y <= K && S - X - Y >= 0) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = Integer.parseInt(sc.next());
		int S = Integer.parseInt(sc.next());
		sc.close();
		int cnt = 0;
		for(int X = 0;X <= K;X++) {
			for(int Y = 0;Y <= K;Y++) {
				if(S - X - Y <= K && S - X - Y >= 0) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	} main {
		Scanner sc = new Scanner(System.in);
		int K = Integer.parseInt(sc.next());
		int S = Integer.parseInt(sc.next());
		sc.close();
		int cnt = 0;
		for(int X = 0;X <= K;X++) {
			for(int Y = 0;Y <= K;Y++) {
				if(S - X - Y <= K && S - X - Y >= 0) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int K = Integer.parseInt(sc.next()); K Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int S = Integer.parseInt(sc.next()); S Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc sc.close() sc.close sc int cnt = 0; cnt 0 for(int X = 0;X <= K;X++) {
			for(int Y = 0;Y <= K;Y++) {
				if(S - X - Y <= K && S - X - Y >= 0) {
					cnt++;
				}
			}
		} int X = 0; int X = 0; X 0 X <= K X K X++ X++ X {
			for(int Y = 0;Y <= K;Y++) {
				if(S - X - Y <= K && S - X - Y >= 0) {
					cnt++;
				}
			}
		} {
			for(int Y = 0;Y <= K;Y++) {
				if(S - X - Y <= K && S - X - Y >= 0) {
					cnt++;
				}
			}
		} for(int Y = 0;Y <= K;Y++) {
				if(S - X - Y <= K && S - X - Y >= 0) {
					cnt++;
				}
			} int Y = 0; int Y = 0; Y 0 Y <= K Y K Y++ Y++ Y {
				if(S - X - Y <= K && S - X - Y >= 0) {
					cnt++;
				}
			} {
				if(S - X - Y <= K && S - X - Y >= 0) {
					cnt++;
				}
			} if(S - X - Y <= K && S - X - Y >= 0) {
					cnt++;
				} S - X - Y <= K && S - X - Y >= 0 S - X - Y <= K S - X - Y S - X - Y S X Y K S - X - Y >= 0 S - X - Y S - X - Y S X Y 0 {
					cnt++;
				} cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = Integer.parseInt(sc.next());
		int S = Integer.parseInt(sc.next());
		sc.close();
		int cnt = 0;
		for(int X = 0;X <= K;X++) {
			for(int Y = 0;Y <= K;Y++) {
				if(S - X - Y <= K && S - X - Y >= 0) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = Integer.parseInt(sc.next());
		int S = Integer.parseInt(sc.next());
		sc.close();
		int cnt = 0;
		for(int X = 0;X <= K;X++) {
			for(int Y = 0;Y <= K;Y++) {
				if(S - X - Y <= K && S - X - Y >= 0) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = Integer.parseInt(sc.next());
		int S = Integer.parseInt(sc.next());
		sc.close();
		int cnt = 0;
		for(int X = 0;X <= K;X++) {
			for(int Y = 0;Y <= K;Y++) {
				if(S - X - Y <= K && S - X - Y >= 0) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
}