import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String[] T = sc.nextLine().split(" ");
    int K = Integer.parseInt(T[0]);
    int S = Integer.parseInt(T[1]);
    
    int ans = 0;
    for(int i = 0; i <= K; i++){
      for(int j = 0; j <= K; j++){
        int k = S-i-j;
        if(i+j+k == S && k >= 0 && k <= 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);
    String[] T = sc.nextLine().split(" ");
    int K = Integer.parseInt(T[0]);
    int S = Integer.parseInt(T[1]);
    
    int ans = 0;
    for(int i = 0; i <= K; i++){
      for(int j = 0; j <= K; j++){
        int k = S-i-j;
        if(i+j+k == S && k >= 0 && k <= K){
          ans++;
        }
      }
    }
    System.out.println(ans);
  }
} Main public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String[] T = sc.nextLine().split(" ");
    int K = Integer.parseInt(T[0]);
    int S = Integer.parseInt(T[1]);
    
    int ans = 0;
    for(int i = 0; i <= K; i++){
      for(int j = 0; j <= K; j++){
        int k = S-i-j;
        if(i+j+k == S && k >= 0 && k <= K){
          ans++;
        }
      }
    }
    System.out.println(ans);
  } main {
    Scanner sc =  new Scanner(System.in);
    String[] T = sc.nextLine().split(" ");
    int K = Integer.parseInt(T[0]);
    int S = Integer.parseInt(T[1]);
    
    int ans = 0;
    for(int i = 0; i <= K; i++){
      for(int j = 0; j <= K; j++){
        int k = S-i-j;
        if(i+j+k == S && k >= 0 && k <= K){
          ans++;
        }
      }
    }
    System.out.println(ans);
  } Scanner sc =  new Scanner(System.in); sc new Scanner(System.in) String[] T = sc.nextLine().split(" "); T sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " int K = Integer.parseInt(T[0]); K Integer.parseInt(T[0]) Integer.parseInt Integer T[0] T 0 int S = Integer.parseInt(T[1]); S Integer.parseInt(T[1]) Integer.parseInt Integer T[1] T 1 int ans = 0; ans 0 for(int i = 0; i <= K; i++){
      for(int j = 0; j <= K; j++){
        int k = S-i-j;
        if(i+j+k == S && k >= 0 && k <= K){
          ans++;
        }
      }
    } int i = 0; int i = 0; i 0 i <= K i K i++ i++ i {
      for(int j = 0; j <= K; j++){
        int k = S-i-j;
        if(i+j+k == S && k >= 0 && k <= K){
          ans++;
        }
      }
    } {
      for(int j = 0; j <= K; j++){
        int k = S-i-j;
        if(i+j+k == S && k >= 0 && k <= K){
          ans++;
        }
      }
    } for(int j = 0; j <= K; j++){
        int k = S-i-j;
        if(i+j+k == S && k >= 0 && k <= K){
          ans++;
        }
      } int j = 0; int j = 0; j 0 j <= K j K j++ j++ j {
        int k = S-i-j;
        if(i+j+k == S && k >= 0 && k <= K){
          ans++;
        }
      } {
        int k = S-i-j;
        if(i+j+k == S && k >= 0 && k <= K){
          ans++;
        }
      } int k = S-i-j; k S-i-j S-i-j S i j if(i+j+k == S && k >= 0 && k <= K){
          ans++;
        } i+j+k == S && k >= 0 && k <= K i+j+k == S && k >= 0 && k <= K i+j+k == S i+j+k i+j+k i j k S k >= 0 k 0 k <= K k 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);
    String[] T = sc.nextLine().split(" ");
    int K = Integer.parseInt(T[0]);
    int S = Integer.parseInt(T[1]);
    
    int ans = 0;
    for(int i = 0; i <= K; i++){
      for(int j = 0; j <= K; j++){
        int k = S-i-j;
        if(i+j+k == S && k >= 0 && k <= K){
          ans++;
        }
      }
    }
    System.out.println(ans);
  }
} public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String[] T = sc.nextLine().split(" ");
    int K = Integer.parseInt(T[0]);
    int S = Integer.parseInt(T[1]);
    
    int ans = 0;
    for(int i = 0; i <= K; i++){
      for(int j = 0; j <= K; j++){
        int k = S-i-j;
        if(i+j+k == S && k >= 0 && k <= 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);
    String[] T = sc.nextLine().split(" ");
    int K = Integer.parseInt(T[0]);
    int S = Integer.parseInt(T[1]);
    
    int ans = 0;
    for(int i = 0; i <= K; i++){
      for(int j = 0; j <= K; j++){
        int k = S-i-j;
        if(i+j+k == S && k >= 0 && k <= K){
          ans++;
        }
      }
    }
    System.out.println(ans);
  }
}