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