import java.util.Scanner;

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

    int K = scanner.nextInt();
    int S = scanner.nextInt();
    int total = 0;
    for (int X = 0; X <= K; X++) {
      total += Math.max(Math.min(K, S - X) - Math.max(S - K - X, 0) + 1, 0);
    }
    System.out.println(total);
  }
} import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int K = scanner.nextInt();
    int S = scanner.nextInt();
    int total = 0;
    for (int X = 0; X <= K; X++) {
      total += Math.max(Math.min(K, S - X) - Math.max(S - K - X, 0) + 1, 0);
    }
    System.out.println(total);
  }
} Main public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int K = scanner.nextInt();
    int S = scanner.nextInt();
    int total = 0;
    for (int X = 0; X <= K; X++) {
      total += Math.max(Math.min(K, S - X) - Math.max(S - K - X, 0) + 1, 0);
    }
    System.out.println(total);
  } main {
    Scanner scanner = new Scanner(System.in);

    int K = scanner.nextInt();
    int S = scanner.nextInt();
    int total = 0;
    for (int X = 0; X <= K; X++) {
      total += Math.max(Math.min(K, S - X) - Math.max(S - K - X, 0) + 1, 0);
    }
    System.out.println(total);
  } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int K = scanner.nextInt(); K scanner.nextInt() scanner.nextInt scanner int S = scanner.nextInt(); S scanner.nextInt() scanner.nextInt scanner int total = 0; total 0 for (int X = 0; X <= K; X++) {
      total += Math.max(Math.min(K, S - X) - Math.max(S - K - X, 0) + 1, 0);
    } int X = 0; int X = 0; X 0 X <= K X K X++ X++ X {
      total += Math.max(Math.min(K, S - X) - Math.max(S - K - X, 0) + 1, 0);
    } {
      total += Math.max(Math.min(K, S - X) - Math.max(S - K - X, 0) + 1, 0);
    } total += Math.max(Math.min(K, S - X) - Math.max(S - K - X, 0) + 1, 0) total Math.max(Math.min(K, S - X) - Math.max(S - K - X, 0) + 1, 0) Math.max Math Math.min(K, S - X) - Math.max(S - K - X, 0) + 1 Math.min(K, S - X) - Math.max(S - K - X, 0) Math.min(K, S - X) Math.min Math K S - X S X Math.max(S - K - X, 0) Math.max Math S - K - X S - K - X S K X 0 1 0 System.out.println(total) System.out.println System.out System System.out total String[] args args public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int K = scanner.nextInt();
    int S = scanner.nextInt();
    int total = 0;
    for (int X = 0; X <= K; X++) {
      total += Math.max(Math.min(K, S - X) - Math.max(S - K - X, 0) + 1, 0);
    }
    System.out.println(total);
  }
} public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int K = scanner.nextInt();
    int S = scanner.nextInt();
    int total = 0;
    for (int X = 0; X <= K; X++) {
      total += Math.max(Math.min(K, S - X) - Math.max(S - K - X, 0) + 1, 0);
    }
    System.out.println(total);
  }
} Main
import java.util.Scanner;

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

    int K = scanner.nextInt();
    int S = scanner.nextInt();
    int total = 0;
    for (int X = 0; X <= K; X++) {
      total += Math.max(Math.min(K, S - X) - Math.max(S - K - X, 0) + 1, 0);
    }
    System.out.println(total);
  }
}
