import java.util.*;

public class Main {
	  public static void main(String args[]){
      		Scanner scan = new Scanner(System.in);
            
            int K = scan.nextInt();
            int S = scan.nextInt();
            
            int x, y, z;
            int ans = 0;
            
            for( x = 0 ; x <= K ; x++ ){
            	for( y = 0 ; y <= K ; y++ ){
                	z = S - x - y;
                    if( z >= 0 && z <= K )ans++;
                }
            }
      
		    System.out.println(ans);
		  }
} import java.util.*; util.* java public class Main {
	  public static void main(String args[]){
      		Scanner scan = new Scanner(System.in);
            
            int K = scan.nextInt();
            int S = scan.nextInt();
            
            int x, y, z;
            int ans = 0;
            
            for( x = 0 ; x <= K ; x++ ){
            	for( y = 0 ; y <= K ; y++ ){
                	z = S - x - y;
                    if( z >= 0 && z <= K )ans++;
                }
            }
      
		    System.out.println(ans);
		  }
} Main public static void main(String args[]){
      		Scanner scan = new Scanner(System.in);
            
            int K = scan.nextInt();
            int S = scan.nextInt();
            
            int x, y, z;
            int ans = 0;
            
            for( x = 0 ; x <= K ; x++ ){
            	for( y = 0 ; y <= K ; y++ ){
                	z = S - x - y;
                    if( z >= 0 && z <= K )ans++;
                }
            }
      
		    System.out.println(ans);
		  } main {
      		Scanner scan = new Scanner(System.in);
            
            int K = scan.nextInt();
            int S = scan.nextInt();
            
            int x, y, z;
            int ans = 0;
            
            for( x = 0 ; x <= K ; x++ ){
            	for( y = 0 ; y <= K ; y++ ){
                	z = S - x - y;
                    if( z >= 0 && z <= K )ans++;
                }
            }
      
		    System.out.println(ans);
		  } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int K = scan.nextInt(); K scan.nextInt() scan.nextInt scan int S = scan.nextInt(); S scan.nextInt() scan.nextInt scan int x x y y z; z int ans = 0; ans 0 for( x = 0 ; x <= K ; x++ ){
            	for( y = 0 ; y <= K ; y++ ){
                	z = S - x - y;
                    if( z >= 0 && z <= K )ans++;
                }
            } x = 0 ; x = 0 x 0 x <= K x K x++ x++ x {
            	for( y = 0 ; y <= K ; y++ ){
                	z = S - x - y;
                    if( z >= 0 && z <= K )ans++;
                }
            } {
            	for( y = 0 ; y <= K ; y++ ){
                	z = S - x - y;
                    if( z >= 0 && z <= K )ans++;
                }
            } for( y = 0 ; y <= K ; y++ ){
                	z = S - x - y;
                    if( z >= 0 && z <= K )ans++;
                } y = 0 ; y = 0 y 0 y <= K y K y++ y++ y {
                	z = S - x - y;
                    if( z >= 0 && z <= K )ans++;
                } {
                	z = S - x - y;
                    if( z >= 0 && z <= K )ans++;
                } 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 System.out.println(ans) System.out.println System.out System System.out ans String args[] args public class Main {
	  public static void main(String args[]){
      		Scanner scan = new Scanner(System.in);
            
            int K = scan.nextInt();
            int S = scan.nextInt();
            
            int x, y, z;
            int ans = 0;
            
            for( x = 0 ; x <= K ; x++ ){
            	for( y = 0 ; y <= K ; y++ ){
                	z = S - x - y;
                    if( z >= 0 && z <= K )ans++;
                }
            }
      
		    System.out.println(ans);
		  }
} public class Main {
	  public static void main(String args[]){
      		Scanner scan = new Scanner(System.in);
            
            int K = scan.nextInt();
            int S = scan.nextInt();
            
            int x, y, z;
            int ans = 0;
            
            for( x = 0 ; x <= K ; x++ ){
            	for( y = 0 ; y <= K ; y++ ){
                	z = S - x - y;
                    if( z >= 0 && z <= K )ans++;
                }
            }
      
		    System.out.println(ans);
		  }
} Main
import java.util.*;

public class Main {
	  public static void main(String args[]){
      		Scanner scan = new Scanner(System.in);
            
            int K = scan.nextInt();
            int S = scan.nextInt();
            
            int x, y, z;
            int ans = 0;
            
            for( x = 0 ; x <= K ; x++ ){
            	for( y = 0 ; y <= K ; y++ ){
                	z = S - x - y;
                    if( z >= 0 && z <= K )ans++;
                }
            }
      
		    System.out.println(ans);
		  }
}