import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int k = scn.nextInt();
		int s = scn.nextInt();
      	int count = 0;
      	for(int x=0; x<=k; ++x){
        	for(int y=0; y<=k; ++y){
	    		if(s>=x+y && s-(x+y)<=k){
            		count = count + 1;
           		}
        	}
    	}
      	System.out.println(count);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int k = scn.nextInt();
		int s = scn.nextInt();
      	int count = 0;
      	for(int x=0; x<=k; ++x){
        	for(int y=0; y<=k; ++y){
	    		if(s>=x+y && s-(x+y)<=k){
            		count = count + 1;
           		}
        	}
    	}
      	System.out.println(count);
	}
} Main public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int k = scn.nextInt();
		int s = scn.nextInt();
      	int count = 0;
      	for(int x=0; x<=k; ++x){
        	for(int y=0; y<=k; ++y){
	    		if(s>=x+y && s-(x+y)<=k){
            		count = count + 1;
           		}
        	}
    	}
      	System.out.println(count);
	} main {
		Scanner scn = new Scanner(System.in);
		int k = scn.nextInt();
		int s = scn.nextInt();
      	int count = 0;
      	for(int x=0; x<=k; ++x){
        	for(int y=0; y<=k; ++y){
	    		if(s>=x+y && s-(x+y)<=k){
            		count = count + 1;
           		}
        	}
    	}
      	System.out.println(count);
	} Scanner scn = new Scanner(System.in); scn new Scanner(System.in) int k = scn.nextInt(); k scn.nextInt() scn.nextInt scn int s = scn.nextInt(); s scn.nextInt() scn.nextInt scn int count = 0; count 0 for(int x=0; x<=k; ++x){
        	for(int y=0; y<=k; ++y){
	    		if(s>=x+y && s-(x+y)<=k){
            		count = count + 1;
           		}
        	}
    	} 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 && s-(x+y)<=k){
            		count = count + 1;
           		}
        	}
    	} {
        	for(int y=0; y<=k; ++y){
	    		if(s>=x+y && s-(x+y)<=k){
            		count = count + 1;
           		}
        	}
    	} for(int y=0; y<=k; ++y){
	    		if(s>=x+y && s-(x+y)<=k){
            		count = count + 1;
           		}
        	} int y=0; int y=0; y 0 y<=k y k ++y ++y y {
	    		if(s>=x+y && s-(x+y)<=k){
            		count = count + 1;
           		}
        	} {
	    		if(s>=x+y && s-(x+y)<=k){
            		count = count + 1;
           		}
        	} if(s>=x+y && s-(x+y)<=k){
            		count = count + 1;
           		} s>=x+y && s-(x+y)<=k s>=x+y s x+y x y s-(x+y)<=k s-(x+y) s (x+y) x y k {
            		count = count + 1;
           		} count = count + 1 count count + 1 count 1 System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int k = scn.nextInt();
		int s = scn.nextInt();
      	int count = 0;
      	for(int x=0; x<=k; ++x){
        	for(int y=0; y<=k; ++y){
	    		if(s>=x+y && s-(x+y)<=k){
            		count = count + 1;
           		}
        	}
    	}
      	System.out.println(count);
	}
} public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int k = scn.nextInt();
		int s = scn.nextInt();
      	int count = 0;
      	for(int x=0; x<=k; ++x){
        	for(int y=0; y<=k; ++y){
	    		if(s>=x+y && s-(x+y)<=k){
            		count = count + 1;
           		}
        	}
    	}
      	System.out.println(count);
	}
} Main
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int k = scn.nextInt();
		int s = scn.nextInt();
      	int count = 0;
      	for(int x=0; x<=k; ++x){
        	for(int y=0; y<=k; ++y){
	    		if(s>=x+y && s-(x+y)<=k){
            		count = count + 1;
           		}
        	}
    	}
      	System.out.println(count);
	}
}
