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());
    int count = 0;
    int z = 0;
    
    //K以下の自然数X,Y,Zの合計がSとなる組み合わせは何通りあるか
    for(int x = 0; x <=K; x++){
      for(int y = 0; y <=K; y++){
        z = S - x - y;
       if(z >= 0 && z <= K) count++;
      }
    }   
    System.out.println(count);      
  }
} 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());
    int count = 0;
    int z = 0;
    
    //K以下の自然数X,Y,Zの合計がSとなる組み合わせは何通りあるか
    for(int x = 0; x <=K; x++){
      for(int y = 0; y <=K; y++){
        z = S - x - y;
       if(z >= 0 && z <= K) count++;
      }
    }   
    System.out.println(count);      
  }
} 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());
    int count = 0;
    int z = 0;
    
    //K以下の自然数X,Y,Zの合計がSとなる組み合わせは何通りあるか
    for(int x = 0; x <=K; x++){
      for(int y = 0; y <=K; y++){
        z = S - x - y;
       if(z >= 0 && z <= K) count++;
      }
    }   
    System.out.println(count);      
  } main {
	Scanner sc = new Scanner(System.in);
    int K = Integer.parseInt(sc.next());
    int S = Integer.parseInt(sc.next());
    int count = 0;
    int z = 0;
    
    //K以下の自然数X,Y,Zの合計がSとなる組み合わせは何通りあるか
    for(int x = 0; x <=K; x++){
      for(int y = 0; y <=K; y++){
        z = S - x - y;
       if(z >= 0 && z <= K) count++;
      }
    }   
    System.out.println(count);      
  } 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 int count = 0; count 0 int z = 0; z 0 for(int x = 0; x <=K; x++){
      for(int y = 0; y <=K; y++){
        z = S - x - y;
       if(z >= 0 && z <= K) count++;
      }
    } int x = 0; int x = 0; x 0 x <=K x K x++ x++ x {
      for(int y = 0; y <=K; y++){
        z = S - x - y;
       if(z >= 0 && z <= K) count++;
      }
    } {
      for(int y = 0; y <=K; y++){
        z = S - x - y;
       if(z >= 0 && z <= K) count++;
      }
    } for(int y = 0; y <=K; y++){
        z = S - x - y;
       if(z >= 0 && z <= K) count++;
      } int y = 0; int y = 0; y 0 y <=K y K y++ y++ y {
        z = S - x - y;
       if(z >= 0 && z <= K) count++;
      } {
        z = S - x - y;
       if(z >= 0 && z <= K) count++;
      } z = S - x - y z S - x - y S - x - y S x y if(z >= 0 && z <= K) count++; z >= 0 && z <= K z >= 0 z 0 z <= K z K count++ count 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){
	Scanner sc = new Scanner(System.in);
    int K = Integer.parseInt(sc.next());
    int S = Integer.parseInt(sc.next());
    int count = 0;
    int z = 0;
    
    //K以下の自然数X,Y,Zの合計がSとなる組み合わせは何通りあるか
    for(int x = 0; x <=K; x++){
      for(int y = 0; y <=K; y++){
        z = S - x - y;
       if(z >= 0 && z <= K) count++;
      }
    }   
    System.out.println(count);      
  }
} 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());
    int count = 0;
    int z = 0;
    
    //K以下の自然数X,Y,Zの合計がSとなる組み合わせは何通りあるか
    for(int x = 0; x <=K; x++){
      for(int y = 0; y <=K; y++){
        z = S - x - y;
       if(z >= 0 && z <= K) count++;
      }
    }   
    System.out.println(count);      
  }
} 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());
    int count = 0;
    int z = 0;
    
    //K以下の自然数X,Y,Zの合計がSとなる組み合わせは何通りあるか
    for(int x = 0; x <=K; x++){
      for(int y = 0; y <=K; y++){
        z = S - x - y;
       if(z >= 0 && z <= K) count++;
      }
    }   
    System.out.println(count);      
  }
}