import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();
        int cnt = 0;
        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= k; y++) {
                int a = s - y - x;
                if (a >= 0 && a <= k) {
                    cnt++;
                }
            }
        }
        System.out.println(cnt);

    }
} import java.math.BigDecimal; BigDecimal java.math import java.util.*; util.* java import java.util.stream.Collectors; Collectors java.util.stream class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();
        int cnt = 0;
        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= k; y++) {
                int a = s - y - x;
                if (a >= 0 && a <= k) {
                    cnt++;
                }
            }
        }
        System.out.println(cnt);

    }
} Main public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();
        int cnt = 0;
        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= k; y++) {
                int a = s - y - x;
                if (a >= 0 && a <= k) {
                    cnt++;
                }
            }
        }
        System.out.println(cnt);

    } main {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();
        int cnt = 0;
        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= k; y++) {
                int a = s - y - x;
                if (a >= 0 && a <= k) {
                    cnt++;
                }
            }
        }
        System.out.println(cnt);

    } 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 cnt = 0; cnt 0 for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= k; y++) {
                int a = s - y - x;
                if (a >= 0 && a <= k) {
                    cnt++;
                }
            }
        } int x = 0; int x = 0; x 0 x <= k x k x++ x++ x {
            for (int y = 0; y <= k; y++) {
                int a = s - y - x;
                if (a >= 0 && a <= k) {
                    cnt++;
                }
            }
        } {
            for (int y = 0; y <= k; y++) {
                int a = s - y - x;
                if (a >= 0 && a <= k) {
                    cnt++;
                }
            }
        } for (int y = 0; y <= k; y++) {
                int a = s - y - x;
                if (a >= 0 && a <= k) {
                    cnt++;
                }
            } int y = 0; int y = 0; y 0 y <= k y k y++ y++ y {
                int a = s - y - x;
                if (a >= 0 && a <= k) {
                    cnt++;
                }
            } {
                int a = s - y - x;
                if (a >= 0 && a <= k) {
                    cnt++;
                }
            } int a = s - y - x; a s - y - x s - y - x s y x if (a >= 0 && a <= k) {
                    cnt++;
                } a >= 0 && a <= k a >= 0 a 0 a <= k a k {
                    cnt++;
                } cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String args[] args
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();
        int cnt = 0;
        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= k; y++) {
                int a = s - y - x;
                if (a >= 0 && a <= k) {
                    cnt++;
                }
            }
        }
        System.out.println(cnt);

    }
}