import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
      Scanner sc = new Scanner(System.in);
      int k = sc.nextInt();
      int s = sc.nextInt();
      sc.close();
      int answer = 0;
      for (int x=0; x<=k; x++) {
        for (int y=0; y<=k; y++) {
          int z = s - x - y;
          if (z >= 0 && z <= k){
            answer++;
          }
        }
      }
      System.out.println(answer);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
      Scanner sc = new Scanner(System.in);
      int k = sc.nextInt();
      int s = sc.nextInt();
      sc.close();
      int answer = 0;
      for (int x=0; x<=k; x++) {
        for (int y=0; y<=k; y++) {
          int z = s - x - y;
          if (z >= 0 && z <= k){
            answer++;
          }
        }
      }
      System.out.println(answer);
    }
} Main public static void main(String[] args) throws Exception {
      Scanner sc = new Scanner(System.in);
      int k = sc.nextInt();
      int s = sc.nextInt();
      sc.close();
      int answer = 0;
      for (int x=0; x<=k; x++) {
        for (int y=0; y<=k; y++) {
          int z = s - x - y;
          if (z >= 0 && z <= k){
            answer++;
          }
        }
      }
      System.out.println(answer);
    } main {
      Scanner sc = new Scanner(System.in);
      int k = sc.nextInt();
      int s = sc.nextInt();
      sc.close();
      int answer = 0;
      for (int x=0; x<=k; x++) {
        for (int y=0; y<=k; y++) {
          int z = s - x - y;
          if (z >= 0 && z <= k){
            answer++;
          }
        }
      }
      System.out.println(answer);
    } 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 sc.close() sc.close sc int answer = 0; answer 0 for (int x=0; x<=k; x++) {
        for (int y=0; y<=k; y++) {
          int z = s - x - y;
          if (z >= 0 && z <= k){
            answer++;
          }
        }
      } int x=0; int x=0; x 0 x<=k x k x++ x++ x {
        for (int y=0; y<=k; y++) {
          int z = s - x - y;
          if (z >= 0 && z <= k){
            answer++;
          }
        }
      } {
        for (int y=0; y<=k; y++) {
          int z = s - x - y;
          if (z >= 0 && z <= k){
            answer++;
          }
        }
      } for (int y=0; y<=k; y++) {
          int z = s - x - y;
          if (z >= 0 && z <= k){
            answer++;
          }
        } int y=0; int y=0; y 0 y<=k y k y++ y++ y {
          int z = s - x - y;
          if (z >= 0 && z <= k){
            answer++;
          }
        } {
          int z = s - x - y;
          if (z >= 0 && z <= k){
            answer++;
          }
        } int z = s - x - y; z s - x - y s - x - y s x y if (z >= 0 && z <= k){
            answer++;
          } z >= 0 && z <= k z >= 0 z 0 z <= k z k {
            answer++;
          } answer++ answer System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main {
    public static void main(String[] args) throws Exception {
      Scanner sc = new Scanner(System.in);
      int k = sc.nextInt();
      int s = sc.nextInt();
      sc.close();
      int answer = 0;
      for (int x=0; x<=k; x++) {
        for (int y=0; y<=k; y++) {
          int z = s - x - y;
          if (z >= 0 && z <= k){
            answer++;
          }
        }
      }
      System.out.println(answer);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
      Scanner sc = new Scanner(System.in);
      int k = sc.nextInt();
      int s = sc.nextInt();
      sc.close();
      int answer = 0;
      for (int x=0; x<=k; x++) {
        for (int y=0; y<=k; y++) {
          int z = s - x - y;
          if (z >= 0 && z <= k){
            answer++;
          }
        }
      }
      System.out.println(answer);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
      Scanner sc = new Scanner(System.in);
      int k = sc.nextInt();
      int s = sc.nextInt();
      sc.close();
      int answer = 0;
      for (int x=0; x<=k; x++) {
        for (int y=0; y<=k; y++) {
          int z = s - x - y;
          if (z >= 0 && z <= k){
            answer++;
          }
        }
      }
      System.out.println(answer);
    }
}
