import java.util.*;
class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int s = sc.nextInt();
    
    //0<=x,y,z<=k
	int sum = 0;
    for(int x=0 ; x<=k ; x++){
      for(int y=0 ; y<=k ; y++){
        int z = s-(x+y);
          if( (0<=z) && (z<=k) ){
            sum++;
          
        }
      }
    }
    System.out.println(sum);
  }
} import java.util.*; util.* java class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int s = sc.nextInt();
    
    //0<=x,y,z<=k
	int sum = 0;
    for(int x=0 ; x<=k ; x++){
      for(int y=0 ; y<=k ; y++){
        int z = s-(x+y);
          if( (0<=z) && (z<=k) ){
            sum++;
          
        }
      }
    }
    System.out.println(sum);
  }
} Main public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int s = sc.nextInt();
    
    //0<=x,y,z<=k
	int sum = 0;
    for(int x=0 ; x<=k ; x++){
      for(int y=0 ; y<=k ; y++){
        int z = s-(x+y);
          if( (0<=z) && (z<=k) ){
            sum++;
          
        }
      }
    }
    System.out.println(sum);
  } main {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int s = sc.nextInt();
    
    //0<=x,y,z<=k
	int sum = 0;
    for(int x=0 ; x<=k ; x++){
      for(int y=0 ; y<=k ; y++){
        int z = s-(x+y);
          if( (0<=z) && (z<=k) ){
            sum++;
          
        }
      }
    }
    System.out.println(sum);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc int s = sc.nextInt(); s sc.nextInt() sc.nextInt sc int sum = 0; sum 0 for(int x=0 ; x<=k ; x++){
      for(int y=0 ; y<=k ; y++){
        int z = s-(x+y);
          if( (0<=z) && (z<=k) ){
            sum++;
          
        }
      }
    } int x=0 ; int x=0 ; x 0 x<=k x k x++ x++ x {
      for(int y=0 ; y<=k ; y++){
        int z = s-(x+y);
          if( (0<=z) && (z<=k) ){
            sum++;
          
        }
      }
    } {
      for(int y=0 ; y<=k ; y++){
        int z = s-(x+y);
          if( (0<=z) && (z<=k) ){
            sum++;
          
        }
      }
    } for(int y=0 ; y<=k ; y++){
        int z = s-(x+y);
          if( (0<=z) && (z<=k) ){
            sum++;
          
        }
      } int y=0 ; int y=0 ; y 0 y<=k y k y++ y++ y {
        int z = s-(x+y);
          if( (0<=z) && (z<=k) ){
            sum++;
          
        }
      } {
        int z = s-(x+y);
          if( (0<=z) && (z<=k) ){
            sum++;
          
        }
      } int z = s-(x+y); z s-(x+y) s (x+y) x y if( (0<=z) && (z<=k) ){
            sum++;
          
        } (0<=z) && (z<=k) (0<=z) 0 z (z<=k) z k {
            sum++;
          
        } sum++ sum System.out.println(sum) System.out.println System.out System System.out sum String[] args args
import java.util.*;
class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int s = sc.nextInt();
    
    //0<=x,y,z<=k
	int sum = 0;
    for(int x=0 ; x<=k ; x++){
      for(int y=0 ; y<=k ; y++){
        int z = s-(x+y);
          if( (0<=z) && (z<=k) ){
            sum++;
          
        }
      }
    }
    System.out.println(sum);
  }
}