import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] argv) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int k = Integer.parseInt(str[0]);
        int n = Integer.parseInt(str[1]);

        int x, y, cnt = 0;
        for (x = 0; x <= k; x++) {
            for (y = 0; y <= k; y++) {
                if ((0 <= n - x - y) && (n - x - y <= k)) cnt++;
            }
        }
        System.out.println(cnt);
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

    public static void main(String[] argv) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int k = Integer.parseInt(str[0]);
        int n = Integer.parseInt(str[1]);

        int x, y, cnt = 0;
        for (x = 0; x <= k; x++) {
            for (y = 0; y <= k; y++) {
                if ((0 <= n - x - y) && (n - x - y <= k)) cnt++;
            }
        }
        System.out.println(cnt);
    }
} Main public static void main(String[] argv) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int k = Integer.parseInt(str[0]);
        int n = Integer.parseInt(str[1]);

        int x, y, cnt = 0;
        for (x = 0; x <= k; x++) {
            for (y = 0; y <= k; y++) {
                if ((0 <= n - x - y) && (n - x - y <= k)) cnt++;
            }
        }
        System.out.println(cnt);
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int k = Integer.parseInt(str[0]);
        int n = Integer.parseInt(str[1]);

        int x, y, cnt = 0;
        for (x = 0; x <= k; x++) {
            for (y = 0; y <= k; y++) {
                if ((0 <= n - x - y) && (n - x - y <= k)) cnt++;
            }
        }
        System.out.println(cnt);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] str = br.readLine().split(" "); str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int k = Integer.parseInt(str[0]); k Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 int n = Integer.parseInt(str[1]); n Integer.parseInt(str[1]) Integer.parseInt Integer str[1] str 1 int x x y y cnt = 0; cnt 0 for (x = 0; x <= k; x++) {
            for (y = 0; y <= k; y++) {
                if ((0 <= n - x - y) && (n - x - y <= k)) cnt++;
            }
        } x = 0; x = 0 x 0 x <= k x k x++ x++ x {
            for (y = 0; y <= k; y++) {
                if ((0 <= n - x - y) && (n - x - y <= k)) cnt++;
            }
        } {
            for (y = 0; y <= k; y++) {
                if ((0 <= n - x - y) && (n - x - y <= k)) cnt++;
            }
        } for (y = 0; y <= k; y++) {
                if ((0 <= n - x - y) && (n - x - y <= k)) cnt++;
            } y = 0; y = 0 y 0 y <= k y k y++ y++ y {
                if ((0 <= n - x - y) && (n - x - y <= k)) cnt++;
            } {
                if ((0 <= n - x - y) && (n - x - y <= k)) cnt++;
            } if ((0 <= n - x - y) && (n - x - y <= k)) cnt++; (0 <= n - x - y) && (n - x - y <= k) (0 <= n - x - y) 0 n - x - y n - x - y n x y (n - x - y <= k) n - x - y n - x - y n x y k cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] argv argv public class Main {

    public static void main(String[] argv) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int k = Integer.parseInt(str[0]);
        int n = Integer.parseInt(str[1]);

        int x, y, cnt = 0;
        for (x = 0; x <= k; x++) {
            for (y = 0; y <= k; y++) {
                if ((0 <= n - x - y) && (n - x - y <= k)) cnt++;
            }
        }
        System.out.println(cnt);
    }
} public class Main {

    public static void main(String[] argv) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int k = Integer.parseInt(str[0]);
        int n = Integer.parseInt(str[1]);

        int x, y, cnt = 0;
        for (x = 0; x <= k; x++) {
            for (y = 0; y <= k; y++) {
                if ((0 <= n - x - y) && (n - x - y <= k)) cnt++;
            }
        }
        System.out.println(cnt);
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] argv) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int k = Integer.parseInt(str[0]);
        int n = Integer.parseInt(str[1]);

        int x, y, cnt = 0;
        for (x = 0; x <= k; x++) {
            for (y = 0; y <= k; y++) {
                if ((0 <= n - x - y) && (n - x - y <= k)) cnt++;
            }
        }
        System.out.println(cnt);
    }
}
