import java.util.*;

public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int ans = 0;
        for (int i = 0; i <= K; i++) {
            for (int j = 0; j <= K; j++) {
                if (i + j <= S && S - (i + j) <= K) {
                    ans++;
                }
            }
        }
        System.out.println(ans);
    }
} import java.util.*; util.* java public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int ans = 0;
        for (int i = 0; i <= K; i++) {
            for (int j = 0; j <= K; j++) {
                if (i + j <= S && S - (i + j) <= K) {
                    ans++;
                }
            }
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        new Main().solve();
    } main {
        new Main().solve();
    } new Main().solve() new Main().solve new Main() String[] args args void solve() {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int ans = 0;
        for (int i = 0; i <= K; i++) {
            for (int j = 0; j <= K; j++) {
                if (i + j <= S && S - (i + j) <= K) {
                    ans++;
                }
            }
        }
        System.out.println(ans);
    } solve {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int ans = 0;
        for (int i = 0; i <= K; i++) {
            for (int j = 0; j <= K; j++) {
                if (i + j <= S && S - (i + j) <= K) {
                    ans++;
                }
            }
        }
        System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc int S = sc.nextInt(); S sc.nextInt() sc.nextInt sc int ans = 0; ans 0 for (int i = 0; i <= K; i++) {
            for (int j = 0; j <= K; j++) {
                if (i + j <= S && S - (i + j) <= K) {
                    ans++;
                }
            }
        } int i = 0; int i = 0; i 0 i <= K i K i++ i++ i {
            for (int j = 0; j <= K; j++) {
                if (i + j <= S && S - (i + j) <= K) {
                    ans++;
                }
            }
        } {
            for (int j = 0; j <= K; j++) {
                if (i + j <= S && S - (i + j) <= K) {
                    ans++;
                }
            }
        } for (int j = 0; j <= K; j++) {
                if (i + j <= S && S - (i + j) <= K) {
                    ans++;
                }
            } int j = 0; int j = 0; j 0 j <= K j K j++ j++ j {
                if (i + j <= S && S - (i + j) <= K) {
                    ans++;
                }
            } {
                if (i + j <= S && S - (i + j) <= K) {
                    ans++;
                }
            } if (i + j <= S && S - (i + j) <= K) {
                    ans++;
                } i + j <= S && S - (i + j) <= K i + j <= S i + j i j S S - (i + j) <= K S - (i + j) S (i + j) i j K {
                    ans++;
                } ans++ ans System.out.println(ans) System.out.println System.out System System.out ans public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int ans = 0;
        for (int i = 0; i <= K; i++) {
            for (int j = 0; j <= K; j++) {
                if (i + j <= S && S - (i + j) <= K) {
                    ans++;
                }
            }
        }
        System.out.println(ans);
    }
} public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int ans = 0;
        for (int i = 0; i <= K; i++) {
            for (int j = 0; j <= K; j++) {
                if (i + j <= S && S - (i + j) <= K) {
                    ans++;
                }
            }
        }
        System.out.println(ans);
    }
} Main
import java.util.*;

public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int ans = 0;
        for (int i = 0; i <= K; i++) {
            for (int j = 0; j <= K; j++) {
                if (i + j <= S && S - (i + j) <= K) {
                    ans++;
                }
            }
        }
        System.out.println(ans);
    }
}