import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int max = Integer.parseInt(sc.next());
        int target = Integer.parseInt(sc.next());
        int cnt = 0;
        for (int i = 0; i <= max; i++) {
            for (int j = 0; j <= max; j++) {
                int total = i + j;
                if (target - total <= max && target - total >= 0) {
                    cnt++;
                }
            }
        }
        System.out.println(cnt);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int max = Integer.parseInt(sc.next());
        int target = Integer.parseInt(sc.next());
        int cnt = 0;
        for (int i = 0; i <= max; i++) {
            for (int j = 0; j <= max; j++) {
                int total = i + j;
                if (target - total <= max && target - total >= 0) {
                    cnt++;
                }
            }
        }
        System.out.println(cnt);
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int max = Integer.parseInt(sc.next());
        int target = Integer.parseInt(sc.next());
        int cnt = 0;
        for (int i = 0; i <= max; i++) {
            for (int j = 0; j <= max; j++) {
                int total = i + j;
                if (target - total <= max && target - total >= 0) {
                    cnt++;
                }
            }
        }
        System.out.println(cnt);
    } main {
        Scanner sc = new Scanner(System.in);
        int max = Integer.parseInt(sc.next());
        int target = Integer.parseInt(sc.next());
        int cnt = 0;
        for (int i = 0; i <= max; i++) {
            for (int j = 0; j <= max; j++) {
                int total = i + j;
                if (target - total <= max && target - total >= 0) {
                    cnt++;
                }
            }
        }
        System.out.println(cnt);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int max = Integer.parseInt(sc.next()); max Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int target = Integer.parseInt(sc.next()); target Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int cnt = 0; cnt 0 for (int i = 0; i <= max; i++) {
            for (int j = 0; j <= max; j++) {
                int total = i + j;
                if (target - total <= max && target - total >= 0) {
                    cnt++;
                }
            }
        } int i = 0; int i = 0; i 0 i <= max i max i++ i++ i {
            for (int j = 0; j <= max; j++) {
                int total = i + j;
                if (target - total <= max && target - total >= 0) {
                    cnt++;
                }
            }
        } {
            for (int j = 0; j <= max; j++) {
                int total = i + j;
                if (target - total <= max && target - total >= 0) {
                    cnt++;
                }
            }
        } for (int j = 0; j <= max; j++) {
                int total = i + j;
                if (target - total <= max && target - total >= 0) {
                    cnt++;
                }
            } int j = 0; int j = 0; j 0 j <= max j max j++ j++ j {
                int total = i + j;
                if (target - total <= max && target - total >= 0) {
                    cnt++;
                }
            } {
                int total = i + j;
                if (target - total <= max && target - total >= 0) {
                    cnt++;
                }
            } int total = i + j; total i + j i j if (target - total <= max && target - total >= 0) {
                    cnt++;
                } target - total <= max && target - total >= 0 target - total <= max target - total target total max target - total >= 0 target - total target total 0 {
                    cnt++;
                } cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int max = Integer.parseInt(sc.next());
        int target = Integer.parseInt(sc.next());
        int cnt = 0;
        for (int i = 0; i <= max; i++) {
            for (int j = 0; j <= max; j++) {
                int total = i + j;
                if (target - total <= max && target - total >= 0) {
                    cnt++;
                }
            }
        }
        System.out.println(cnt);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int max = Integer.parseInt(sc.next());
        int target = Integer.parseInt(sc.next());
        int cnt = 0;
        for (int i = 0; i <= max; i++) {
            for (int j = 0; j <= max; j++) {
                int total = i + j;
                if (target - total <= max && target - total >= 0) {
                    cnt++;
                }
            }
        }
        System.out.println(cnt);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int max = Integer.parseInt(sc.next());
        int target = Integer.parseInt(sc.next());
        int cnt = 0;
        for (int i = 0; i <= max; i++) {
            for (int j = 0; j <= max; j++) {
                int total = i + j;
                if (target - total <= max && target - total >= 0) {
                    cnt++;
                }
            }
        }
        System.out.println(cnt);
    }
}