import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    try {
      long k = scanner.nextLong();
      long s = scanner.nextLong();
      long ans = 0;
      for (long x = 0; x <= k; x++) {
        for (long y = 0; y <= k; y++) {
          long z = s - x - y;
          if (0 <= z && z <= k) ans++;
        }
      }
      
      System.out.println(ans);
    } finally {
      scanner.close();
    }
  }
} import java.util.*; util.* java public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    try {
      long k = scanner.nextLong();
      long s = scanner.nextLong();
      long ans = 0;
      for (long x = 0; x <= k; x++) {
        for (long y = 0; y <= k; y++) {
          long z = s - x - y;
          if (0 <= z && z <= k) ans++;
        }
      }
      
      System.out.println(ans);
    } finally {
      scanner.close();
    }
  }
} Main public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    try {
      long k = scanner.nextLong();
      long s = scanner.nextLong();
      long ans = 0;
      for (long x = 0; x <= k; x++) {
        for (long y = 0; y <= k; y++) {
          long z = s - x - y;
          if (0 <= z && z <= k) ans++;
        }
      }
      
      System.out.println(ans);
    } finally {
      scanner.close();
    }
  } main {
    Scanner scanner = new Scanner(System.in);
    try {
      long k = scanner.nextLong();
      long s = scanner.nextLong();
      long ans = 0;
      for (long x = 0; x <= k; x++) {
        for (long y = 0; y <= k; y++) {
          long z = s - x - y;
          if (0 <= z && z <= k) ans++;
        }
      }
      
      System.out.println(ans);
    } finally {
      scanner.close();
    }
  } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) try {
      long k = scanner.nextLong();
      long s = scanner.nextLong();
      long ans = 0;
      for (long x = 0; x <= k; x++) {
        for (long y = 0; y <= k; y++) {
          long z = s - x - y;
          if (0 <= z && z <= k) ans++;
        }
      }
      
      System.out.println(ans);
    } finally {
      scanner.close();
    } {
      scanner.close();
    } scanner.close() scanner.close scanner {
      long k = scanner.nextLong();
      long s = scanner.nextLong();
      long ans = 0;
      for (long x = 0; x <= k; x++) {
        for (long y = 0; y <= k; y++) {
          long z = s - x - y;
          if (0 <= z && z <= k) ans++;
        }
      }
      
      System.out.println(ans);
    } long k = scanner.nextLong(); k scanner.nextLong() scanner.nextLong scanner long s = scanner.nextLong(); s scanner.nextLong() scanner.nextLong scanner long ans = 0; ans 0 for (long x = 0; x <= k; x++) {
        for (long y = 0; y <= k; y++) {
          long z = s - x - y;
          if (0 <= z && z <= k) ans++;
        }
      } long x = 0; long x = 0; x 0 x <= k x k x++ x++ x {
        for (long y = 0; y <= k; y++) {
          long z = s - x - y;
          if (0 <= z && z <= k) ans++;
        }
      } {
        for (long y = 0; y <= k; y++) {
          long z = s - x - y;
          if (0 <= z && z <= k) ans++;
        }
      } for (long y = 0; y <= k; y++) {
          long z = s - x - y;
          if (0 <= z && z <= k) ans++;
        } long y = 0; long y = 0; y 0 y <= k y k y++ y++ y {
          long z = s - x - y;
          if (0 <= z && z <= k) ans++;
        } {
          long z = s - x - y;
          if (0 <= z && z <= k) ans++;
        } long z = s - x - y; z s - x - y s - x - y s x y if (0 <= z && z <= k) ans++; 0 <= z && z <= k 0 <= z 0 z z <= k z k ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    try {
      long k = scanner.nextLong();
      long s = scanner.nextLong();
      long ans = 0;
      for (long x = 0; x <= k; x++) {
        for (long y = 0; y <= k; y++) {
          long z = s - x - y;
          if (0 <= z && z <= k) ans++;
        }
      }
      
      System.out.println(ans);
    } finally {
      scanner.close();
    }
  }
} public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    try {
      long k = scanner.nextLong();
      long s = scanner.nextLong();
      long ans = 0;
      for (long x = 0; x <= k; x++) {
        for (long y = 0; y <= k; y++) {
          long z = s - x - y;
          if (0 <= z && z <= k) ans++;
        }
      }
      
      System.out.println(ans);
    } finally {
      scanner.close();
    }
  }
} Main
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    try {
      long k = scanner.nextLong();
      long s = scanner.nextLong();
      long ans = 0;
      for (long x = 0; x <= k; x++) {
        for (long y = 0; y <= k; y++) {
          long z = s - x - y;
          if (0 <= z && z <= k) ans++;
        }
      }
      
      System.out.println(ans);
    } finally {
      scanner.close();
    }
  }
}
