//intのオーバーフローに気をつけろ,AGCはだいたいlongにしておけ
//毎回余りを求めることでオーバーフローしなくなる
//nextLineよりnextだ
//charは''で囲うんだぞ
//読み込みは先に全部やっておけ
//for文を回す回数に気をつけろ

import java.util.Scanner;

public class Main {

	public static void main(String args[]) throws InterruptedException {
		    Scanner sc = new Scanner(System.in);
		    
		    int x = sc.nextInt();
		    int wa = sc.nextInt();
		    int ans = 0;
		    
		    for(int i = 0; i <= x;i++) {
		    	for(int j = 0; j <= x; j++) {
		    		if(0 <= wa-i-j && wa-i-j <= x ) {
		    			ans++;
		    		}
		    	}
		    }
		    System.out.println(ans);
		    sc.close(); }

	public static void saiki(int a, String b) {
		//再帰コーディングのお手本

		if(a == 0) {
			System.out.println(b);
		}else {
			for(char ch = 'a'; ch <= 'c'; ch++) {
				saiki(a-1,b + ch);
			}
		}
	}

	public static  int gcd(int a, int b) {
	    if (a < b) {
	        int tmp = a;
	        a = b;
	        b = tmp;
	    }

	    int r = -1;
	    while (r != 0) {
	        r = a % b;
	        a = b;
	        b = r;
	    }

	    return a;
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String args[]) throws InterruptedException {
		    Scanner sc = new Scanner(System.in);
		    
		    int x = sc.nextInt();
		    int wa = sc.nextInt();
		    int ans = 0;
		    
		    for(int i = 0; i <= x;i++) {
		    	for(int j = 0; j <= x; j++) {
		    		if(0 <= wa-i-j && wa-i-j <= x ) {
		    			ans++;
		    		}
		    	}
		    }
		    System.out.println(ans);
		    sc.close(); }

	public static void saiki(int a, String b) {
		//再帰コーディングのお手本

		if(a == 0) {
			System.out.println(b);
		}else {
			for(char ch = 'a'; ch <= 'c'; ch++) {
				saiki(a-1,b + ch);
			}
		}
	}

	public static  int gcd(int a, int b) {
	    if (a < b) {
	        int tmp = a;
	        a = b;
	        b = tmp;
	    }

	    int r = -1;
	    while (r != 0) {
	        r = a % b;
	        a = b;
	        b = r;
	    }

	    return a;
	}
} Main public static void main(String args[]) throws InterruptedException {
		    Scanner sc = new Scanner(System.in);
		    
		    int x = sc.nextInt();
		    int wa = sc.nextInt();
		    int ans = 0;
		    
		    for(int i = 0; i <= x;i++) {
		    	for(int j = 0; j <= x; j++) {
		    		if(0 <= wa-i-j && wa-i-j <= x ) {
		    			ans++;
		    		}
		    	}
		    }
		    System.out.println(ans);
		    sc.close(); } main {
		    Scanner sc = new Scanner(System.in);
		    
		    int x = sc.nextInt();
		    int wa = sc.nextInt();
		    int ans = 0;
		    
		    for(int i = 0; i <= x;i++) {
		    	for(int j = 0; j <= x; j++) {
		    		if(0 <= wa-i-j && wa-i-j <= x ) {
		    			ans++;
		    		}
		    	}
		    }
		    System.out.println(ans);
		    sc.close(); } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int wa = sc.nextInt(); wa sc.nextInt() sc.nextInt sc int ans = 0; ans 0 for(int i = 0; i <= x;i++) {
		    	for(int j = 0; j <= x; j++) {
		    		if(0 <= wa-i-j && wa-i-j <= x ) {
		    			ans++;
		    		}
		    	}
		    } int i = 0; int i = 0; i 0 i <= x i x i++ i++ i {
		    	for(int j = 0; j <= x; j++) {
		    		if(0 <= wa-i-j && wa-i-j <= x ) {
		    			ans++;
		    		}
		    	}
		    } {
		    	for(int j = 0; j <= x; j++) {
		    		if(0 <= wa-i-j && wa-i-j <= x ) {
		    			ans++;
		    		}
		    	}
		    } for(int j = 0; j <= x; j++) {
		    		if(0 <= wa-i-j && wa-i-j <= x ) {
		    			ans++;
		    		}
		    	} int j = 0; int j = 0; j 0 j <= x j x j++ j++ j {
		    		if(0 <= wa-i-j && wa-i-j <= x ) {
		    			ans++;
		    		}
		    	} {
		    		if(0 <= wa-i-j && wa-i-j <= x ) {
		    			ans++;
		    		}
		    	} if(0 <= wa-i-j && wa-i-j <= x ) {
		    			ans++;
		    		} 0 <= wa-i-j && wa-i-j <= x 0 <= wa-i-j 0 wa-i-j wa-i-j wa i j wa-i-j <= x wa-i-j wa-i-j wa i j x {
		    			ans++;
		    		} ans++ ans System.out.println(ans) System.out.println System.out System System.out ans sc.close() sc.close sc String args[] args public static void saiki(int a, String b) {
		//再帰コーディングのお手本

		if(a == 0) {
			System.out.println(b);
		}else {
			for(char ch = 'a'; ch <= 'c'; ch++) {
				saiki(a-1,b + ch);
			}
		}
	} saiki {
		//再帰コーディングのお手本

		if(a == 0) {
			System.out.println(b);
		}else {
			for(char ch = 'a'; ch <= 'c'; ch++) {
				saiki(a-1,b + ch);
			}
		}
	} if(a == 0) {
			System.out.println(b);
		}else {
			for(char ch = 'a'; ch <= 'c'; ch++) {
				saiki(a-1,b + ch);
			}
		} a == 0 a 0 {
			System.out.println(b);
		} System.out.println(b) System.out.println System.out System System.out b {
			for(char ch = 'a'; ch <= 'c'; ch++) {
				saiki(a-1,b + ch);
			}
		} for(char ch = 'a'; ch <= 'c'; ch++) {
				saiki(a-1,b + ch);
			} char ch = 'a'; char ch = 'a'; ch 'a' ch <= 'c' ch 'c' ch++ ch++ ch {
				saiki(a-1,b + ch);
			} {
				saiki(a-1,b + ch);
			} saiki(a-1,b + ch) saiki a-1 a 1 b + ch b ch int a a String b b public static  int gcd(int a, int b) {
	    if (a < b) {
	        int tmp = a;
	        a = b;
	        b = tmp;
	    }

	    int r = -1;
	    while (r != 0) {
	        r = a % b;
	        a = b;
	        b = r;
	    }

	    return a;
	} gcd {
	    if (a < b) {
	        int tmp = a;
	        a = b;
	        b = tmp;
	    }

	    int r = -1;
	    while (r != 0) {
	        r = a % b;
	        a = b;
	        b = r;
	    }

	    return a;
	} if (a < b) {
	        int tmp = a;
	        a = b;
	        b = tmp;
	    } a < b a b {
	        int tmp = a;
	        a = b;
	        b = tmp;
	    } int tmp = a; tmp a a = b a b b = tmp b tmp int r = -1; r -1 1 while (r != 0) {
	        r = a % b;
	        a = b;
	        b = r;
	    } r != 0 r 0 {
	        r = a % b;
	        a = b;
	        b = r;
	    } r = a % b r a % b a b a = b a b b = r b r return a; a int a a int b b public class Main {

	public static void main(String args[]) throws InterruptedException {
		    Scanner sc = new Scanner(System.in);
		    
		    int x = sc.nextInt();
		    int wa = sc.nextInt();
		    int ans = 0;
		    
		    for(int i = 0; i <= x;i++) {
		    	for(int j = 0; j <= x; j++) {
		    		if(0 <= wa-i-j && wa-i-j <= x ) {
		    			ans++;
		    		}
		    	}
		    }
		    System.out.println(ans);
		    sc.close(); }

	public static void saiki(int a, String b) {
		//再帰コーディングのお手本

		if(a == 0) {
			System.out.println(b);
		}else {
			for(char ch = 'a'; ch <= 'c'; ch++) {
				saiki(a-1,b + ch);
			}
		}
	}

	public static  int gcd(int a, int b) {
	    if (a < b) {
	        int tmp = a;
	        a = b;
	        b = tmp;
	    }

	    int r = -1;
	    while (r != 0) {
	        r = a % b;
	        a = b;
	        b = r;
	    }

	    return a;
	}
} public class Main {

	public static void main(String args[]) throws InterruptedException {
		    Scanner sc = new Scanner(System.in);
		    
		    int x = sc.nextInt();
		    int wa = sc.nextInt();
		    int ans = 0;
		    
		    for(int i = 0; i <= x;i++) {
		    	for(int j = 0; j <= x; j++) {
		    		if(0 <= wa-i-j && wa-i-j <= x ) {
		    			ans++;
		    		}
		    	}
		    }
		    System.out.println(ans);
		    sc.close(); }

	public static void saiki(int a, String b) {
		//再帰コーディングのお手本

		if(a == 0) {
			System.out.println(b);
		}else {
			for(char ch = 'a'; ch <= 'c'; ch++) {
				saiki(a-1,b + ch);
			}
		}
	}

	public static  int gcd(int a, int b) {
	    if (a < b) {
	        int tmp = a;
	        a = b;
	        b = tmp;
	    }

	    int r = -1;
	    while (r != 0) {
	        r = a % b;
	        a = b;
	        b = r;
	    }

	    return a;
	}
} Main
//intのオーバーフローに気をつけろ,AGCはだいたいlongにしておけ
//毎回余りを求めることでオーバーフローしなくなる
//nextLineよりnextだ
//charは''で囲うんだぞ
//読み込みは先に全部やっておけ
//for文を回す回数に気をつけろ

import java.util.Scanner;

public class Main {

	public static void main(String args[]) throws InterruptedException {
		    Scanner sc = new Scanner(System.in);
		    
		    int x = sc.nextInt();
		    int wa = sc.nextInt();
		    int ans = 0;
		    
		    for(int i = 0; i <= x;i++) {
		    	for(int j = 0; j <= x; j++) {
		    		if(0 <= wa-i-j && wa-i-j <= x ) {
		    			ans++;
		    		}
		    	}
		    }
		    System.out.println(ans);
		    sc.close(); }

	public static void saiki(int a, String b) {
		//再帰コーディングのお手本

		if(a == 0) {
			System.out.println(b);
		}else {
			for(char ch = 'a'; ch <= 'c'; ch++) {
				saiki(a-1,b + ch);
			}
		}
	}

	public static  int gcd(int a, int b) {
	    if (a < b) {
	        int tmp = a;
	        a = b;
	        b = tmp;
	    }

	    int r = -1;
	    while (r != 0) {
	        r = a % b;
	        a = b;
	        b = r;
	    }

	    return a;
	}
}
