import java.util.*;

class Main {
  public static void main(String[] args) {
	Scanner scanner = new Scanner(System.in);
    
    int N = scanner.nextInt(); //next(文字列), nextDouble, nextLine(1行)とか
	int S = scanner.nextInt();
    
    int ans = 0;
    for (int i = 0; i <= N; i++){
      for (int j = 0; j <= N; j++){
        if (0 <= S - i - j && S - i - j <= N ){
          ans++;
        }
      }
    }
    System.out.println(ans);
  }
} import java.util.*; util.* java class Main {
  public static void main(String[] args) {
	Scanner scanner = new Scanner(System.in);
    
    int N = scanner.nextInt(); //next(文字列), nextDouble, nextLine(1行)とか
	int S = scanner.nextInt();
    
    int ans = 0;
    for (int i = 0; i <= N; i++){
      for (int j = 0; j <= N; j++){
        if (0 <= S - i - j && S - i - j <= N ){
          ans++;
        }
      }
    }
    System.out.println(ans);
  }
} Main public static void main(String[] args) {
	Scanner scanner = new Scanner(System.in);
    
    int N = scanner.nextInt(); //next(文字列), nextDouble, nextLine(1行)とか
	int S = scanner.nextInt();
    
    int ans = 0;
    for (int i = 0; i <= N; i++){
      for (int j = 0; j <= N; j++){
        if (0 <= S - i - j && S - i - j <= N ){
          ans++;
        }
      }
    }
    System.out.println(ans);
  } main {
	Scanner scanner = new Scanner(System.in);
    
    int N = scanner.nextInt(); //next(文字列), nextDouble, nextLine(1行)とか
	int S = scanner.nextInt();
    
    int ans = 0;
    for (int i = 0; i <= N; i++){
      for (int j = 0; j <= N; j++){
        if (0 <= S - i - j && S - i - j <= N ){
          ans++;
        }
      }
    }
    System.out.println(ans);
  } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner int S = scanner.nextInt(); S scanner.nextInt() scanner.nextInt scanner int ans = 0; ans 0 for (int i = 0; i <= N; i++){
      for (int j = 0; j <= N; j++){
        if (0 <= S - i - j && S - i - j <= N ){
          ans++;
        }
      }
    } int i = 0; int i = 0; i 0 i <= N i N i++ i++ i {
      for (int j = 0; j <= N; j++){
        if (0 <= S - i - j && S - i - j <= N ){
          ans++;
        }
      }
    } {
      for (int j = 0; j <= N; j++){
        if (0 <= S - i - j && S - i - j <= N ){
          ans++;
        }
      }
    } for (int j = 0; j <= N; j++){
        if (0 <= S - i - j && S - i - j <= N ){
          ans++;
        }
      } int j = 0; int j = 0; j 0 j <= N j N j++ j++ j {
        if (0 <= S - i - j && S - i - j <= N ){
          ans++;
        }
      } {
        if (0 <= S - i - j && S - i - j <= N ){
          ans++;
        }
      } if (0 <= S - i - j && S - i - j <= N ){
          ans++;
        } 0 <= S - i - j && S - i - j <= N 0 <= S - i - j 0 S - i - j S - i - j S i j S - i - j <= N S - i - j S - i - j S i j N {
          ans++;
        } ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.*;

class Main {
  public static void main(String[] args) {
	Scanner scanner = new Scanner(System.in);
    
    int N = scanner.nextInt(); //next(文字列), nextDouble, nextLine(1行)とか
	int S = scanner.nextInt();
    
    int ans = 0;
    for (int i = 0; i <= N; i++){
      for (int j = 0; j <= N; j++){
        if (0 <= S - i - j && S - i - j <= N ){
          ans++;
        }
      }
    }
    System.out.println(ans);
  }
}
