
import java.util.*;

public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int S = sc.nextInt();
    int cnt = 0;

    for (int x = 0; x <= K; x++) {
      for (int y = 0; y <= K; y++) {
        int z = S - x - y;
        if (0 <= z && z <= K) cnt++;
      }
    }

    System.out.println(cnt);
  }
} import java.util.*; util.* java public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int S = sc.nextInt();
    int cnt = 0;

    for (int x = 0; x <= K; x++) {
      for (int y = 0; y <= K; y++) {
        int z = S - x - y;
        if (0 <= z && z <= K) cnt++;
      }
    }

    System.out.println(cnt);
  }
} Main public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int S = sc.nextInt();
    int cnt = 0;

    for (int x = 0; x <= K; x++) {
      for (int y = 0; y <= K; y++) {
        int z = S - x - y;
        if (0 <= z && z <= K) cnt++;
      }
    }

    System.out.println(cnt);
  } main {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int S = sc.nextInt();
    int cnt = 0;

    for (int x = 0; x <= K; x++) {
      for (int y = 0; y <= K; y++) {
        int z = S - x - y;
        if (0 <= z && z <= K) cnt++;
      }
    }

    System.out.println(cnt);
  } @SuppressWarnings("resource")
    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 cnt = 0; cnt 0 for (int x = 0; x <= K; x++) {
      for (int y = 0; y <= K; y++) {
        int z = S - x - y;
        if (0 <= z && z <= K) cnt++;
      }
    } 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 (0 <= z && z <= K) cnt++;
      }
    } {
      for (int y = 0; y <= K; y++) {
        int z = S - x - y;
        if (0 <= z && z <= K) cnt++;
      }
    } for (int y = 0; y <= K; y++) {
        int z = S - x - y;
        if (0 <= z && z <= K) cnt++;
      } int y = 0; int y = 0; y 0 y <= K y K y++ y++ y {
        int z = S - x - y;
        if (0 <= z && z <= K) cnt++;
      } {
        int z = S - x - y;
        if (0 <= z && z <= K) cnt++;
      } int z = S - x - y; z S - x - y S - x - y S x y if (0 <= z && z <= K) cnt++; 0 <= z && z <= K 0 <= z 0 z z <= K z K cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int S = sc.nextInt();
    int cnt = 0;

    for (int x = 0; x <= K; x++) {
      for (int y = 0; y <= K; y++) {
        int z = S - x - y;
        if (0 <= z && z <= K) cnt++;
      }
    }

    System.out.println(cnt);
  }
} public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int S = sc.nextInt();
    int cnt = 0;

    for (int x = 0; x <= K; x++) {
      for (int y = 0; y <= K; y++) {
        int z = S - x - y;
        if (0 <= z && z <= K) cnt++;
      }
    }

    System.out.println(cnt);
  }
} Main

import java.util.*;

public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int S = sc.nextInt();
    int cnt = 0;

    for (int x = 0; x <= K; x++) {
      for (int y = 0; y <= K; y++) {
        int z = S - x - y;
        if (0 <= z && z <= K) cnt++;
      }
    }

    System.out.println(cnt);
  }
}
