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