import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

class Main {
    public static void main(final String[] args) throws Exception {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> inputString = Arrays.asList(br.readLine().split(" "));
            List<Integer> numbers = new ArrayList<>();
            for (String str : inputString) {
                numbers.add(Integer.parseInt(str));
            }

            int ans = 0;
            for (int i = 0; i <= numbers.get(0); i++) {
                for (int j = 0; j <= numbers.get(0); j++) {
                    int k = numbers.get(1) - i - j;
                    if (0 <= k && k <= numbers.get(0)) {
                        ans++;
                    }
                }
            }

            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.List; List java.util class Main {
    public static void main(final String[] args) throws Exception {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> inputString = Arrays.asList(br.readLine().split(" "));
            List<Integer> numbers = new ArrayList<>();
            for (String str : inputString) {
                numbers.add(Integer.parseInt(str));
            }

            int ans = 0;
            for (int i = 0; i <= numbers.get(0); i++) {
                for (int j = 0; j <= numbers.get(0); j++) {
                    int k = numbers.get(1) - i - j;
                    if (0 <= k && k <= numbers.get(0)) {
                        ans++;
                    }
                }
            }

            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
} Main public static void main(final String[] args) throws Exception {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> inputString = Arrays.asList(br.readLine().split(" "));
            List<Integer> numbers = new ArrayList<>();
            for (String str : inputString) {
                numbers.add(Integer.parseInt(str));
            }

            int ans = 0;
            for (int i = 0; i <= numbers.get(0); i++) {
                for (int j = 0; j <= numbers.get(0); j++) {
                    int k = numbers.get(1) - i - j;
                    if (0 <= k && k <= numbers.get(0)) {
                        ans++;
                    }
                }
            }

            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    } main {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> inputString = Arrays.asList(br.readLine().split(" "));
            List<Integer> numbers = new ArrayList<>();
            for (String str : inputString) {
                numbers.add(Integer.parseInt(str));
            }

            int ans = 0;
            for (int i = 0; i <= numbers.get(0); i++) {
                for (int j = 0; j <= numbers.get(0); j++) {
                    int k = numbers.get(1) - i - j;
                    if (0 <= k && k <= numbers.get(0)) {
                        ans++;
                    }
                }
            }

            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    } try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> inputString = Arrays.asList(br.readLine().split(" "));
            List<Integer> numbers = new ArrayList<>();
            for (String str : inputString) {
                numbers.add(Integer.parseInt(str));
            }

            int ans = 0;
            for (int i = 0; i <= numbers.get(0); i++) {
                for (int j = 0; j <= numbers.get(0); j++) {
                    int k = numbers.get(1) - i - j;
                    if (0 <= k && k <= numbers.get(0)) {
                        ans++;
                    }
                }
            }

            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } IOException | NumberFormatException e {
            e.printStackTrace();
            System.exit(0);
        } e.printStackTrace() e.printStackTrace e System.exit(0) System.exit System 0 catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        } final Exception e {
            e.printStackTrace();
            System.exit(0);
        } e.printStackTrace() e.printStackTrace e System.exit(0) System.exit System 0 {
            List<String> inputString = Arrays.asList(br.readLine().split(" "));
            List<Integer> numbers = new ArrayList<>();
            for (String str : inputString) {
                numbers.add(Integer.parseInt(str));
            }

            int ans = 0;
            for (int i = 0; i <= numbers.get(0); i++) {
                for (int j = 0; j <= numbers.get(0); j++) {
                    int k = numbers.get(1) - i - j;
                    if (0 <= k && k <= numbers.get(0)) {
                        ans++;
                    }
                }
            }

            System.out.println(ans);
        } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) new BufferedReader(new InputStreamReader(System.in)) List<String> inputString = Arrays.asList(br.readLine().split(" ")); inputString Arrays.asList(br.readLine().split(" ")) Arrays.asList Arrays br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " List<Integer> numbers = new ArrayList<>(); numbers new ArrayList<>() for (String str : inputString) {
                numbers.add(Integer.parseInt(str));
            } String str inputString {
                numbers.add(Integer.parseInt(str));
            } {
                numbers.add(Integer.parseInt(str));
            } numbers.add(Integer.parseInt(str)) numbers.add numbers Integer.parseInt(str) Integer.parseInt Integer str int ans = 0; ans 0 for (int i = 0; i <= numbers.get(0); i++) {
                for (int j = 0; j <= numbers.get(0); j++) {
                    int k = numbers.get(1) - i - j;
                    if (0 <= k && k <= numbers.get(0)) {
                        ans++;
                    }
                }
            } int i = 0; int i = 0; i 0 i <= numbers.get(0) i numbers.get(0) numbers.get numbers 0 i++ i++ i {
                for (int j = 0; j <= numbers.get(0); j++) {
                    int k = numbers.get(1) - i - j;
                    if (0 <= k && k <= numbers.get(0)) {
                        ans++;
                    }
                }
            } {
                for (int j = 0; j <= numbers.get(0); j++) {
                    int k = numbers.get(1) - i - j;
                    if (0 <= k && k <= numbers.get(0)) {
                        ans++;
                    }
                }
            } for (int j = 0; j <= numbers.get(0); j++) {
                    int k = numbers.get(1) - i - j;
                    if (0 <= k && k <= numbers.get(0)) {
                        ans++;
                    }
                } int j = 0; int j = 0; j 0 j <= numbers.get(0) j numbers.get(0) numbers.get numbers 0 j++ j++ j {
                    int k = numbers.get(1) - i - j;
                    if (0 <= k && k <= numbers.get(0)) {
                        ans++;
                    }
                } {
                    int k = numbers.get(1) - i - j;
                    if (0 <= k && k <= numbers.get(0)) {
                        ans++;
                    }
                } int k = numbers.get(1) - i - j; k numbers.get(1) - i - j numbers.get(1) - i - j numbers.get(1) numbers.get numbers 1 i j if (0 <= k && k <= numbers.get(0)) {
                        ans++;
                    } 0 <= k && k <= numbers.get(0) 0 <= k 0 k k <= numbers.get(0) k numbers.get(0) numbers.get numbers 0 {
                        ans++;
                    } ans++ ans System.out.println(ans) System.out.println System.out System System.out ans final String[] args args
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

class Main {
    public static void main(final String[] args) throws Exception {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> inputString = Arrays.asList(br.readLine().split(" "));
            List<Integer> numbers = new ArrayList<>();
            for (String str : inputString) {
                numbers.add(Integer.parseInt(str));
            }

            int ans = 0;
            for (int i = 0; i <= numbers.get(0); i++) {
                for (int j = 0; j <= numbers.get(0); j++) {
                    int k = numbers.get(1) - i - j;
                    if (0 <= k && k <= numbers.get(0)) {
                        ans++;
                    }
                }
            }

            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}