
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=0;j<=K;j++){
        if(i+j>S){
          break;
        }
        if(S-i-j>=0&&S-i-j<=K){
            answer++;
        }
      }
    }
    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=0;j<=K;j++){
        if(i+j>S){
          break;
        }
        if(S-i-j>=0&&S-i-j<=K){
            answer++;
        }
      }
    }
    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=0;j<=K;j++){
        if(i+j>S){
          break;
        }
        if(S-i-j>=0&&S-i-j<=K){
            answer++;
        }
      }
    }
    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=0;j<=K;j++){
        if(i+j>S){
          break;
        }
        if(S-i-j>=0&&S-i-j<=K){
            answer++;
        }
      }
    }
    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=0;j<=K;j++){
        if(i+j>S){
          break;
        }
        if(S-i-j>=0&&S-i-j<=K){
            answer++;
        }
      }
    } int i=0; int i=0; i 0 i<=K i K i++ i++ i {
      if(i>S){
        break;
      }
      for(int j=0;j<=K;j++){
        if(i+j>S){
          break;
        }
        if(S-i-j>=0&&S-i-j<=K){
            answer++;
        }
      }
    } {
      if(i>S){
        break;
      }
      for(int j=0;j<=K;j++){
        if(i+j>S){
          break;
        }
        if(S-i-j>=0&&S-i-j<=K){
            answer++;
        }
      }
    } if(i>S){
        break;
      } i>S i S {
        break;
      } break; for(int j=0;j<=K;j++){
        if(i+j>S){
          break;
        }
        if(S-i-j>=0&&S-i-j<=K){
            answer++;
        }
      } int j=0; int j=0; j 0 j<=K j K j++ j++ j {
        if(i+j>S){
          break;
        }
        if(S-i-j>=0&&S-i-j<=K){
            answer++;
        }
      } {
        if(i+j>S){
          break;
        }
        if(S-i-j>=0&&S-i-j<=K){
            answer++;
        }
      } if(i+j>S){
          break;
        } i+j>S i+j i j S {
          break;
        } break; if(S-i-j>=0&&S-i-j<=K){
            answer++;
        } S-i-j>=0&&S-i-j<=K S-i-j>=0 S-i-j S-i-j S i j 0 S-i-j<=K S-i-j S-i-j S i j K {
            answer++;
        } answer++ answer 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=0;j<=K;j++){
        if(i+j>S){
          break;
        }
        if(S-i-j>=0&&S-i-j<=K){
            answer++;
        }
      }
    }
    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=0;j<=K;j++){
        if(i+j>S){
          break;
        }
        if(S-i-j>=0&&S-i-j<=K){
            answer++;
        }
      }
    }
    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=0;j<=K;j++){
        if(i+j>S){
          break;
        }
        if(S-i-j>=0&&S-i-j<=K){
            answer++;
        }
      }
    }
    System.out.println(answer);
  }
  

  
}
