import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int k = scan.nextInt();
    int s = scan.nextInt();
    long sum = 0;
    int check = s-2*k;
    int initial = (int) Math.max(0,check);

    for (int i=initial;i<=k;i++){
      int current = s-i;
      int start = 0;
      int end = k;
      if (current > 2*k){
        continue;
      }
      else if (current > k){
        start = current-k;
        sum += end-start+1;
      }
      else if (current >= 0){
        end = current;
        sum += end-start+1;
      }
    }
    System.out.println(sum);

  }

} import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int k = scan.nextInt();
    int s = scan.nextInt();
    long sum = 0;
    int check = s-2*k;
    int initial = (int) Math.max(0,check);

    for (int i=initial;i<=k;i++){
      int current = s-i;
      int start = 0;
      int end = k;
      if (current > 2*k){
        continue;
      }
      else if (current > k){
        start = current-k;
        sum += end-start+1;
      }
      else if (current >= 0){
        end = current;
        sum += end-start+1;
      }
    }
    System.out.println(sum);

  }

} Main public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int k = scan.nextInt();
    int s = scan.nextInt();
    long sum = 0;
    int check = s-2*k;
    int initial = (int) Math.max(0,check);

    for (int i=initial;i<=k;i++){
      int current = s-i;
      int start = 0;
      int end = k;
      if (current > 2*k){
        continue;
      }
      else if (current > k){
        start = current-k;
        sum += end-start+1;
      }
      else if (current >= 0){
        end = current;
        sum += end-start+1;
      }
    }
    System.out.println(sum);

  } main {
    Scanner scan = new Scanner(System.in);
    int k = scan.nextInt();
    int s = scan.nextInt();
    long sum = 0;
    int check = s-2*k;
    int initial = (int) Math.max(0,check);

    for (int i=initial;i<=k;i++){
      int current = s-i;
      int start = 0;
      int end = k;
      if (current > 2*k){
        continue;
      }
      else if (current > k){
        start = current-k;
        sum += end-start+1;
      }
      else if (current >= 0){
        end = current;
        sum += end-start+1;
      }
    }
    System.out.println(sum);

  } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int k = scan.nextInt(); k scan.nextInt() scan.nextInt scan int s = scan.nextInt(); s scan.nextInt() scan.nextInt scan long sum = 0; sum 0 int check = s-2*k; check s-2*k s 2*k 2 k int initial = (int) Math.max(0,check); initial (int) Math.max(0,check) Math.max Math 0 check for (int i=initial;i<=k;i++){
      int current = s-i;
      int start = 0;
      int end = k;
      if (current > 2*k){
        continue;
      }
      else if (current > k){
        start = current-k;
        sum += end-start+1;
      }
      else if (current >= 0){
        end = current;
        sum += end-start+1;
      }
    } int i=initial; int i=initial; i initial i<=k i k i++ i++ i {
      int current = s-i;
      int start = 0;
      int end = k;
      if (current > 2*k){
        continue;
      }
      else if (current > k){
        start = current-k;
        sum += end-start+1;
      }
      else if (current >= 0){
        end = current;
        sum += end-start+1;
      }
    } {
      int current = s-i;
      int start = 0;
      int end = k;
      if (current > 2*k){
        continue;
      }
      else if (current > k){
        start = current-k;
        sum += end-start+1;
      }
      else if (current >= 0){
        end = current;
        sum += end-start+1;
      }
    } int current = s-i; current s-i s i int start = 0; start 0 int end = k; end k if (current > 2*k){
        continue;
      }
      else if (current > k){
        start = current-k;
        sum += end-start+1;
      }
      else if (current >= 0){
        end = current;
        sum += end-start+1;
      } current > 2*k current 2*k 2 k {
        continue;
      } continue; if (current > k){
        start = current-k;
        sum += end-start+1;
      }
      else if (current >= 0){
        end = current;
        sum += end-start+1;
      } current > k current k {
        start = current-k;
        sum += end-start+1;
      } start = current-k start current-k current k sum += end-start+1 sum end-start+1 end-start end start 1 if (current >= 0){
        end = current;
        sum += end-start+1;
      } current >= 0 current 0 {
        end = current;
        sum += end-start+1;
      } end = current end current sum += end-start+1 sum end-start+1 end-start end start 1 System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int k = scan.nextInt();
    int s = scan.nextInt();
    long sum = 0;
    int check = s-2*k;
    int initial = (int) Math.max(0,check);

    for (int i=initial;i<=k;i++){
      int current = s-i;
      int start = 0;
      int end = k;
      if (current > 2*k){
        continue;
      }
      else if (current > k){
        start = current-k;
        sum += end-start+1;
      }
      else if (current >= 0){
        end = current;
        sum += end-start+1;
      }
    }
    System.out.println(sum);

  }

} public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int k = scan.nextInt();
    int s = scan.nextInt();
    long sum = 0;
    int check = s-2*k;
    int initial = (int) Math.max(0,check);

    for (int i=initial;i<=k;i++){
      int current = s-i;
      int start = 0;
      int end = k;
      if (current > 2*k){
        continue;
      }
      else if (current > k){
        start = current-k;
        sum += end-start+1;
      }
      else if (current >= 0){
        end = current;
        sum += end-start+1;
      }
    }
    System.out.println(sum);

  }

} Main
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int k = scan.nextInt();
    int s = scan.nextInt();
    long sum = 0;
    int check = s-2*k;
    int initial = (int) Math.max(0,check);

    for (int i=initial;i<=k;i++){
      int current = s-i;
      int start = 0;
      int end = k;
      if (current > 2*k){
        continue;
      }
      else if (current > k){
        start = current-k;
        sum += end-start+1;
      }
      else if (current >= 0){
        end = current;
        sum += end-start+1;
      }
    }
    System.out.println(sum);

  }

}
