import java.util.*;

class Main {

  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);

    int K = sc.nextInt();
    int S = sc.nextInt();
    int count = 0;
    for (int a = 0; a <= K; a++) {
      for (int b = 0; b <= K; b++) {
        if (S - (a + b) <= K && S - (a + b) >= 0) count++;
      }
    }
    System.out.println(count);
  }
} import java.util.*; util.* java class Main {

  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);

    int K = sc.nextInt();
    int S = sc.nextInt();
    int count = 0;
    for (int a = 0; a <= K; a++) {
      for (int b = 0; b <= K; b++) {
        if (S - (a + b) <= K && S - (a + b) >= 0) count++;
      }
    }
    System.out.println(count);
  }
} Main public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);

    int K = sc.nextInt();
    int S = sc.nextInt();
    int count = 0;
    for (int a = 0; a <= K; a++) {
      for (int b = 0; b <= K; b++) {
        if (S - (a + b) <= K && S - (a + b) >= 0) count++;
      }
    }
    System.out.println(count);
  } main {
    Scanner sc = new Scanner(System.in);

    int K = sc.nextInt();
    int S = sc.nextInt();
    int count = 0;
    for (int a = 0; a <= K; a++) {
      for (int b = 0; b <= K; b++) {
        if (S - (a + b) <= K && S - (a + b) >= 0) count++;
      }
    }
    System.out.println(count);
  } 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 count = 0; count 0 for (int a = 0; a <= K; a++) {
      for (int b = 0; b <= K; b++) {
        if (S - (a + b) <= K && S - (a + b) >= 0) count++;
      }
    } int a = 0; int a = 0; a 0 a <= K a K a++ a++ a {
      for (int b = 0; b <= K; b++) {
        if (S - (a + b) <= K && S - (a + b) >= 0) count++;
      }
    } {
      for (int b = 0; b <= K; b++) {
        if (S - (a + b) <= K && S - (a + b) >= 0) count++;
      }
    } for (int b = 0; b <= K; b++) {
        if (S - (a + b) <= K && S - (a + b) >= 0) count++;
      } int b = 0; int b = 0; b 0 b <= K b K b++ b++ b {
        if (S - (a + b) <= K && S - (a + b) >= 0) count++;
      } {
        if (S - (a + b) <= K && S - (a + b) >= 0) count++;
      } if (S - (a + b) <= K && S - (a + b) >= 0) count++; S - (a + b) <= K && S - (a + b) >= 0 S - (a + b) <= K S - (a + b) S (a + b) a b K S - (a + b) >= 0 S - (a + b) S (a + b) a b 0 count++ count System.out.println(count) System.out.println System.out System System.out count String args[] args
import java.util.*;

class Main {

  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);

    int K = sc.nextInt();
    int S = sc.nextInt();
    int count = 0;
    for (int a = 0; a <= K; a++) {
      for (int b = 0; b <= K; b++) {
        if (S - (a + b) <= K && S - (a + b) >= 0) count++;
      }
    }
    System.out.println(count);
  }
}
