import java.io.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] data = br.readLine().split(" ");
    
    long k = Long.parseLong(data[0]);
    long s = Long.parseLong(data[1]);
  
    long result = 0;
    
    for (int i=0; i<=k; i++){
      result += getNumAllocation(s-i, k);
    }
    
    System.out.println(result);
  }
  public static long getNumAllocation(long sum, long max){
    if (sum < 0){
      return 0;
    } else if (sum <= max){
      return sum+1;
    } else if (sum <= max*2){
      return 2*max-sum+1;
    } else {
      return 0;
    }
  }
} import java.io.*; io.* java public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] data = br.readLine().split(" ");
    
    long k = Long.parseLong(data[0]);
    long s = Long.parseLong(data[1]);
  
    long result = 0;
    
    for (int i=0; i<=k; i++){
      result += getNumAllocation(s-i, k);
    }
    
    System.out.println(result);
  }
  public static long getNumAllocation(long sum, long max){
    if (sum < 0){
      return 0;
    } else if (sum <= max){
      return sum+1;
    } else if (sum <= max*2){
      return 2*max-sum+1;
    } else {
      return 0;
    }
  }
} Main public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] data = br.readLine().split(" ");
    
    long k = Long.parseLong(data[0]);
    long s = Long.parseLong(data[1]);
  
    long result = 0;
    
    for (int i=0; i<=k; i++){
      result += getNumAllocation(s-i, k);
    }
    
    System.out.println(result);
  } main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] data = br.readLine().split(" ");
    
    long k = Long.parseLong(data[0]);
    long s = Long.parseLong(data[1]);
  
    long result = 0;
    
    for (int i=0; i<=k; i++){
      result += getNumAllocation(s-i, k);
    }
    
    System.out.println(result);
  } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] data = br.readLine().split(" "); data br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " long k = Long.parseLong(data[0]); k Long.parseLong(data[0]) Long.parseLong Long data[0] data 0 long s = Long.parseLong(data[1]); s Long.parseLong(data[1]) Long.parseLong Long data[1] data 1 long result = 0; result 0 for (int i=0; i<=k; i++){
      result += getNumAllocation(s-i, k);
    } int i=0; int i=0; i 0 i<=k i k i++ i++ i {
      result += getNumAllocation(s-i, k);
    } {
      result += getNumAllocation(s-i, k);
    } result += getNumAllocation(s-i, k) result getNumAllocation(s-i, k) getNumAllocation s-i s i k System.out.println(result) System.out.println System.out System System.out result String[] args args public static long getNumAllocation(long sum, long max){
    if (sum < 0){
      return 0;
    } else if (sum <= max){
      return sum+1;
    } else if (sum <= max*2){
      return 2*max-sum+1;
    } else {
      return 0;
    }
  } getNumAllocation {
    if (sum < 0){
      return 0;
    } else if (sum <= max){
      return sum+1;
    } else if (sum <= max*2){
      return 2*max-sum+1;
    } else {
      return 0;
    }
  } if (sum < 0){
      return 0;
    } else if (sum <= max){
      return sum+1;
    } else if (sum <= max*2){
      return 2*max-sum+1;
    } else {
      return 0;
    } sum < 0 sum 0 {
      return 0;
    } return 0; 0 if (sum <= max){
      return sum+1;
    } else if (sum <= max*2){
      return 2*max-sum+1;
    } else {
      return 0;
    } sum <= max sum max {
      return sum+1;
    } return sum+1; sum+1 sum 1 if (sum <= max*2){
      return 2*max-sum+1;
    } else {
      return 0;
    } sum <= max*2 sum max*2 max 2 {
      return 2*max-sum+1;
    } return 2*max-sum+1; 2*max-sum+1 2*max-sum 2*max 2 max sum 1 {
      return 0;
    } return 0; 0 long sum sum long max max public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] data = br.readLine().split(" ");
    
    long k = Long.parseLong(data[0]);
    long s = Long.parseLong(data[1]);
  
    long result = 0;
    
    for (int i=0; i<=k; i++){
      result += getNumAllocation(s-i, k);
    }
    
    System.out.println(result);
  }
  public static long getNumAllocation(long sum, long max){
    if (sum < 0){
      return 0;
    } else if (sum <= max){
      return sum+1;
    } else if (sum <= max*2){
      return 2*max-sum+1;
    } else {
      return 0;
    }
  }
} public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] data = br.readLine().split(" ");
    
    long k = Long.parseLong(data[0]);
    long s = Long.parseLong(data[1]);
  
    long result = 0;
    
    for (int i=0; i<=k; i++){
      result += getNumAllocation(s-i, k);
    }
    
    System.out.println(result);
  }
  public static long getNumAllocation(long sum, long max){
    if (sum < 0){
      return 0;
    } else if (sum <= max){
      return sum+1;
    } else if (sum <= max*2){
      return 2*max-sum+1;
    } else {
      return 0;
    }
  }
} Main
import java.io.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] data = br.readLine().split(" ");
    
    long k = Long.parseLong(data[0]);
    long s = Long.parseLong(data[1]);
  
    long result = 0;
    
    for (int i=0; i<=k; i++){
      result += getNumAllocation(s-i, k);
    }
    
    System.out.println(result);
  }
  public static long getNumAllocation(long sum, long max){
    if (sum < 0){
      return 0;
    } else if (sum <= max){
      return sum+1;
    } else if (sum <= max*2){
      return 2*max-sum+1;
    } else {
      return 0;
    }
  }
}
