import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = 0;
        for (int i = 0; i <= k; i++) {
            for (int j = 0; j <= k; j++) {
                int sum = i + j;
                if (sum <= s && s - sum <= k) {
                    result++;
                }
            }
        }

        // 出力
        System.out.println(result);
    }
} import java.util.*; util.* java public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = 0;
        for (int i = 0; i <= k; i++) {
            for (int j = 0; j <= k; j++) {
                int sum = i + j;
                if (sum <= s && s - sum <= k) {
                    result++;
                }
            }
        }

        // 出力
        System.out.println(result);
    }
} Main public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = 0;
        for (int i = 0; i <= k; i++) {
            for (int j = 0; j <= k; j++) {
                int sum = i + j;
                if (sum <= s && s - sum <= k) {
                    result++;
                }
            }
        }

        // 出力
        System.out.println(result);
    } main {

        // 入力
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = 0;
        for (int i = 0; i <= k; i++) {
            for (int j = 0; j <= k; j++) {
                int sum = i + j;
                if (sum <= s && s - sum <= k) {
                    result++;
                }
            }
        }

        // 出力
        System.out.println(result);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int k = Integer.parseInt(sc.next()); k Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int s = Integer.parseInt(sc.next()); s Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc sc.close() sc.close sc int result = 0; result 0 for (int i = 0; i <= k; i++) {
            for (int j = 0; j <= k; j++) {
                int sum = i + j;
                if (sum <= s && s - sum <= k) {
                    result++;
                }
            }
        } int i = 0; int i = 0; i 0 i <= k i k i++ i++ i {
            for (int j = 0; j <= k; j++) {
                int sum = i + j;
                if (sum <= s && s - sum <= k) {
                    result++;
                }
            }
        } {
            for (int j = 0; j <= k; j++) {
                int sum = i + j;
                if (sum <= s && s - sum <= k) {
                    result++;
                }
            }
        } for (int j = 0; j <= k; j++) {
                int sum = i + j;
                if (sum <= s && s - sum <= k) {
                    result++;
                }
            } int j = 0; int j = 0; j 0 j <= k j k j++ j++ j {
                int sum = i + j;
                if (sum <= s && s - sum <= k) {
                    result++;
                }
            } {
                int sum = i + j;
                if (sum <= s && s - sum <= k) {
                    result++;
                }
            } int sum = i + j; sum i + j i j if (sum <= s && s - sum <= k) {
                    result++;
                } sum <= s && s - sum <= k sum <= s sum s s - sum <= k s - sum s sum k {
                    result++;
                } result++ result System.out.println(result) System.out.println System.out System System.out result String args[] args public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = 0;
        for (int i = 0; i <= k; i++) {
            for (int j = 0; j <= k; j++) {
                int sum = i + j;
                if (sum <= s && s - sum <= k) {
                    result++;
                }
            }
        }

        // 出力
        System.out.println(result);
    }
} public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = 0;
        for (int i = 0; i <= k; i++) {
            for (int j = 0; j <= k; j++) {
                int sum = i + j;
                if (sum <= s && s - sum <= k) {
                    result++;
                }
            }
        }

        // 出力
        System.out.println(result);
    }
} Main
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = 0;
        for (int i = 0; i <= k; i++) {
            for (int j = 0; j <= k; j++) {
                int sum = i + j;
                if (sum <= s && s - sum <= k) {
                    result++;
                }
            }
        }

        // 出力
        System.out.println(result);
    }
}
