fork download
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4. public static void main(String[] args) {
  5. Scanner sc = new Scanner(System.in);
  6. int K = sc.nextInt();
  7. int S = sc.nextInt();
  8. int count = 0;
  9.  
  10. for (int x = 0; x <= K; x++) {
  11. for (int y = 0; y <= K; y++) {
  12. int z = S - x - y;
  13. if (z >= 0 && z <= K) {
  14. count++;
  15. }
  16. }
  17. }
  18.  
  19. System.out.println(count);
  20. sc.close();
  21. }
  22. }
  23.  
Success #stdin #stdout 0.12s 54644KB
stdin
43
52
stdout
1296