
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int S = sc.nextInt();
    int answer=0;
    for(int i=0;i<=K;i++){
      if(i>S){
        break;
      }
      for(int j=i;j<=K;j++){
        if(i+j>S){
          break;
        }
        for(int l=j;l<=K;l++){
          if(i+j+l==S){
              if(i<j&&j<l){
                  answer=answer+6;
              }else if((i==j&&j<l)||(i<j&&j==l)){
                  answer=answer+3;
              }else{
                  answer++;
              }
            
            break;
          }
        }
      }
    }
    System.out.println(answer);
  }
  

  
} import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int S = sc.nextInt();
    int answer=0;
    for(int i=0;i<=K;i++){
      if(i>S){
        break;
      }
      for(int j=i;j<=K;j++){
        if(i+j>S){
          break;
        }
        for(int l=j;l<=K;l++){
          if(i+j+l==S){
              if(i<j&&j<l){
                  answer=answer+6;
              }else if((i==j&&j<l)||(i<j&&j==l)){
                  answer=answer+3;
              }else{
                  answer++;
              }
            
            break;
          }
        }
      }
    }
    System.out.println(answer);
  }
  

  
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int S = sc.nextInt();
    int answer=0;
    for(int i=0;i<=K;i++){
      if(i>S){
        break;
      }
      for(int j=i;j<=K;j++){
        if(i+j>S){
          break;
        }
        for(int l=j;l<=K;l++){
          if(i+j+l==S){
              if(i<j&&j<l){
                  answer=answer+6;
              }else if((i==j&&j<l)||(i<j&&j==l)){
                  answer=answer+3;
              }else{
                  answer++;
              }
            
            break;
          }
        }
      }
    }
    System.out.println(answer);
  } main {
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int S = sc.nextInt();
    int answer=0;
    for(int i=0;i<=K;i++){
      if(i>S){
        break;
      }
      for(int j=i;j<=K;j++){
        if(i+j>S){
          break;
        }
        for(int l=j;l<=K;l++){
          if(i+j+l==S){
              if(i<j&&j<l){
                  answer=answer+6;
              }else if((i==j&&j<l)||(i<j&&j==l)){
                  answer=answer+3;
              }else{
                  answer++;
              }
            
            break;
          }
        }
      }
    }
    System.out.println(answer);
  } 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 answer=0; answer 0 for(int i=0;i<=K;i++){
      if(i>S){
        break;
      }
      for(int j=i;j<=K;j++){
        if(i+j>S){
          break;
        }
        for(int l=j;l<=K;l++){
          if(i+j+l==S){
              if(i<j&&j<l){
                  answer=answer+6;
              }else if((i==j&&j<l)||(i<j&&j==l)){
                  answer=answer+3;
              }else{
                  answer++;
              }
            
            break;
          }
        }
      }
    } int i=0; int i=0; i 0 i<=K i K i++ i++ i {
      if(i>S){
        break;
      }
      for(int j=i;j<=K;j++){
        if(i+j>S){
          break;
        }
        for(int l=j;l<=K;l++){
          if(i+j+l==S){
              if(i<j&&j<l){
                  answer=answer+6;
              }else if((i==j&&j<l)||(i<j&&j==l)){
                  answer=answer+3;
              }else{
                  answer++;
              }
            
            break;
          }
        }
      }
    } {
      if(i>S){
        break;
      }
      for(int j=i;j<=K;j++){
        if(i+j>S){
          break;
        }
        for(int l=j;l<=K;l++){
          if(i+j+l==S){
              if(i<j&&j<l){
                  answer=answer+6;
              }else if((i==j&&j<l)||(i<j&&j==l)){
                  answer=answer+3;
              }else{
                  answer++;
              }
            
            break;
          }
        }
      }
    } if(i>S){
        break;
      } i>S i S {
        break;
      } break; for(int j=i;j<=K;j++){
        if(i+j>S){
          break;
        }
        for(int l=j;l<=K;l++){
          if(i+j+l==S){
              if(i<j&&j<l){
                  answer=answer+6;
              }else if((i==j&&j<l)||(i<j&&j==l)){
                  answer=answer+3;
              }else{
                  answer++;
              }
            
            break;
          }
        }
      } int j=i; int j=i; j i j<=K j K j++ j++ j {
        if(i+j>S){
          break;
        }
        for(int l=j;l<=K;l++){
          if(i+j+l==S){
              if(i<j&&j<l){
                  answer=answer+6;
              }else if((i==j&&j<l)||(i<j&&j==l)){
                  answer=answer+3;
              }else{
                  answer++;
              }
            
            break;
          }
        }
      } {
        if(i+j>S){
          break;
        }
        for(int l=j;l<=K;l++){
          if(i+j+l==S){
              if(i<j&&j<l){
                  answer=answer+6;
              }else if((i==j&&j<l)||(i<j&&j==l)){
                  answer=answer+3;
              }else{
                  answer++;
              }
            
            break;
          }
        }
      } if(i+j>S){
          break;
        } i+j>S i+j i j S {
          break;
        } break; for(int l=j;l<=K;l++){
          if(i+j+l==S){
              if(i<j&&j<l){
                  answer=answer+6;
              }else if((i==j&&j<l)||(i<j&&j==l)){
                  answer=answer+3;
              }else{
                  answer++;
              }
            
            break;
          }
        } int l=j; int l=j; l j l<=K l K l++ l++ l {
          if(i+j+l==S){
              if(i<j&&j<l){
                  answer=answer+6;
              }else if((i==j&&j<l)||(i<j&&j==l)){
                  answer=answer+3;
              }else{
                  answer++;
              }
            
            break;
          }
        } {
          if(i+j+l==S){
              if(i<j&&j<l){
                  answer=answer+6;
              }else if((i==j&&j<l)||(i<j&&j==l)){
                  answer=answer+3;
              }else{
                  answer++;
              }
            
            break;
          }
        } if(i+j+l==S){
              if(i<j&&j<l){
                  answer=answer+6;
              }else if((i==j&&j<l)||(i<j&&j==l)){
                  answer=answer+3;
              }else{
                  answer++;
              }
            
            break;
          } i+j+l==S i+j+l i+j+l i j l S {
              if(i<j&&j<l){
                  answer=answer+6;
              }else if((i==j&&j<l)||(i<j&&j==l)){
                  answer=answer+3;
              }else{
                  answer++;
              }
            
            break;
          } if(i<j&&j<l){
                  answer=answer+6;
              }else if((i==j&&j<l)||(i<j&&j==l)){
                  answer=answer+3;
              }else{
                  answer++;
              } i<j&&j<l i<j i j j<l j l {
                  answer=answer+6;
              } answer=answer+6 answer answer+6 answer 6 if((i==j&&j<l)||(i<j&&j==l)){
                  answer=answer+3;
              }else{
                  answer++;
              } (i==j&&j<l)||(i<j&&j==l) (i==j&&j<l) i==j i j j<l j l (i<j&&j==l) i<j i j j==l j l {
                  answer=answer+3;
              } answer=answer+3 answer answer+3 answer 3 {
                  answer++;
              } answer++ answer break; System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int S = sc.nextInt();
    int answer=0;
    for(int i=0;i<=K;i++){
      if(i>S){
        break;
      }
      for(int j=i;j<=K;j++){
        if(i+j>S){
          break;
        }
        for(int l=j;l<=K;l++){
          if(i+j+l==S){
              if(i<j&&j<l){
                  answer=answer+6;
              }else if((i==j&&j<l)||(i<j&&j==l)){
                  answer=answer+3;
              }else{
                  answer++;
              }
            
            break;
          }
        }
      }
    }
    System.out.println(answer);
  }
  

  
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int S = sc.nextInt();
    int answer=0;
    for(int i=0;i<=K;i++){
      if(i>S){
        break;
      }
      for(int j=i;j<=K;j++){
        if(i+j>S){
          break;
        }
        for(int l=j;l<=K;l++){
          if(i+j+l==S){
              if(i<j&&j<l){
                  answer=answer+6;
              }else if((i==j&&j<l)||(i<j&&j==l)){
                  answer=answer+3;
              }else{
                  answer++;
              }
            
            break;
          }
        }
      }
    }
    System.out.println(answer);
  }
  

  
} Main

import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int S = sc.nextInt();
    int answer=0;
    for(int i=0;i<=K;i++){
      if(i>S){
        break;
      }
      for(int j=i;j<=K;j++){
        if(i+j>S){
          break;
        }
        for(int l=j;l<=K;l++){
          if(i+j+l==S){
              if(i<j&&j<l){
                  answer=answer+6;
              }else if((i==j&&j<l)||(i<j&&j==l)){
                  answer=answer+3;
              }else{
                  answer++;
              }
            
            break;
          }
        }
      }
    }
    System.out.println(answer);
  }
  

  
}
