import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int k = in.nextInt(), s = in.nextInt();
        int res = 0;
        for (int i = 0; i <= k; ++i) {
            for (int j = 0; j <= k; ++j) {
                int dif = s - i - j;
                if (dif >= 0 && dif <= k) {
                    ++res;
                }
            }
        }
        System.out.println(res);
    }
}
 import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ; IF_ACMPEQ com.sun.org.apache.bcel.internal.generic import java.util.Arrays; Arrays java.util import java.util.HashSet; HashSet java.util import java.util.Scanner; Scanner java.util import java.util.Set; Set java.util public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int k = in.nextInt(), s = in.nextInt();
        int res = 0;
        for (int i = 0; i <= k; ++i) {
            for (int j = 0; j <= k; ++j) {
                int dif = s - i - j;
                if (dif >= 0 && dif <= k) {
                    ++res;
                }
            }
        }
        System.out.println(res);
    }
} Main public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int k = in.nextInt(), s = in.nextInt();
        int res = 0;
        for (int i = 0; i <= k; ++i) {
            for (int j = 0; j <= k; ++j) {
                int dif = s - i - j;
                if (dif >= 0 && dif <= k) {
                    ++res;
                }
            }
        }
        System.out.println(res);
    } main {
        Scanner in = new Scanner(System.in);
        int k = in.nextInt(), s = in.nextInt();
        int res = 0;
        for (int i = 0; i <= k; ++i) {
            for (int j = 0; j <= k; ++j) {
                int dif = s - i - j;
                if (dif >= 0 && dif <= k) {
                    ++res;
                }
            }
        }
        System.out.println(res);
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) int k = in.nextInt() k in.nextInt() in.nextInt in s = in.nextInt(); s in.nextInt() in.nextInt in int res = 0; res 0 for (int i = 0; i <= k; ++i) {
            for (int j = 0; j <= k; ++j) {
                int dif = s - i - j;
                if (dif >= 0 && dif <= k) {
                    ++res;
                }
            }
        } int i = 0; int i = 0; i 0 i <= k i k ++i ++i i {
            for (int j = 0; j <= k; ++j) {
                int dif = s - i - j;
                if (dif >= 0 && dif <= k) {
                    ++res;
                }
            }
        } {
            for (int j = 0; j <= k; ++j) {
                int dif = s - i - j;
                if (dif >= 0 && dif <= k) {
                    ++res;
                }
            }
        } for (int j = 0; j <= k; ++j) {
                int dif = s - i - j;
                if (dif >= 0 && dif <= k) {
                    ++res;
                }
            } int j = 0; int j = 0; j 0 j <= k j k ++j ++j j {
                int dif = s - i - j;
                if (dif >= 0 && dif <= k) {
                    ++res;
                }
            } {
                int dif = s - i - j;
                if (dif >= 0 && dif <= k) {
                    ++res;
                }
            } int dif = s - i - j; dif s - i - j s - i - j s i j if (dif >= 0 && dif <= k) {
                    ++res;
                } dif >= 0 && dif <= k dif >= 0 dif 0 dif <= k dif k {
                    ++res;
                } ++res res System.out.println(res) System.out.println System.out System System.out res String[] args args public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int k = in.nextInt(), s = in.nextInt();
        int res = 0;
        for (int i = 0; i <= k; ++i) {
            for (int j = 0; j <= k; ++j) {
                int dif = s - i - j;
                if (dif >= 0 && dif <= k) {
                    ++res;
                }
            }
        }
        System.out.println(res);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int k = in.nextInt(), s = in.nextInt();
        int res = 0;
        for (int i = 0; i <= k; ++i) {
            for (int j = 0; j <= k; ++j) {
                int dif = s - i - j;
                if (dif >= 0 && dif <= k) {
                    ++res;
                }
            }
        }
        System.out.println(res);
    }
} Main
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int k = in.nextInt(), s = in.nextInt();
        int res = 0;
        for (int i = 0; i <= k; ++i) {
            for (int j = 0; j <= k; ++j) {
                int dif = s - i - j;
                if (dif >= 0 && dif <= k) {
                    ++res;
                }
            }
        }
        System.out.println(res);
    }
}

