import java.io.*;
import java.util.*;
public class Main {
    private static MyScanner scanner;
 
    public static void main (String[] args){
        Main instance = new Main();
        scanner = instance.new MyScanner();
        instance.solve();
    }
 
    private void solve() {
        try {
            int K = scanner.nextInt();
            int S = scanner.nextInt();
            int count = 0;
            for (int i = 0; i <= K; i++) {
                int X = i;
                for (int j = 0; j <= K; j++) {
                    int Y = j;
                    if (X + Y > S) {
                        break;
                    }
                    if (S - X - Y <= K) {
                        count++;
                    }
                }
            }
            System.out.println(count);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
 
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String line = br.readLine();
            while (line.equals("")) {
                line = br.readLine();
            }
            s = line.split(reg, 0);
            i = 0;
            return s[i++];
        }
 
        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }
 
        public double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
 
        public long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }
    }
} import java.io.*; io.* java import java.util.*; util.* java public class Main {
    private static MyScanner scanner;
 
    public static void main (String[] args){
        Main instance = new Main();
        scanner = instance.new MyScanner();
        instance.solve();
    }
 
    private void solve() {
        try {
            int K = scanner.nextInt();
            int S = scanner.nextInt();
            int count = 0;
            for (int i = 0; i <= K; i++) {
                int X = i;
                for (int j = 0; j <= K; j++) {
                    int Y = j;
                    if (X + Y > S) {
                        break;
                    }
                    if (S - X - Y <= K) {
                        count++;
                    }
                }
            }
            System.out.println(count);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
 
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String line = br.readLine();
            while (line.equals("")) {
                line = br.readLine();
            }
            s = line.split(reg, 0);
            i = 0;
            return s[i++];
        }
 
        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }
 
        public double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
 
        public long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }
    }
} Main private static MyScanner scanner; scanner public static void main (String[] args){
        Main instance = new Main();
        scanner = instance.new MyScanner();
        instance.solve();
    } main {
        Main instance = new Main();
        scanner = instance.new MyScanner();
        instance.solve();
    } Main instance = new Main(); instance new Main() scanner = instance.new MyScanner() scanner instance.new MyScanner() instance instance instance.solve() instance.solve instance String[] args args private void solve() {
        try {
            int K = scanner.nextInt();
            int S = scanner.nextInt();
            int count = 0;
            for (int i = 0; i <= K; i++) {
                int X = i;
                for (int j = 0; j <= K; j++) {
                    int Y = j;
                    if (X + Y > S) {
                        break;
                    }
                    if (S - X - Y <= K) {
                        count++;
                    }
                }
            }
            System.out.println(count);
        } catch (Exception e) {
            e.printStackTrace();
        }
    } solve {
        try {
            int K = scanner.nextInt();
            int S = scanner.nextInt();
            int count = 0;
            for (int i = 0; i <= K; i++) {
                int X = i;
                for (int j = 0; j <= K; j++) {
                    int Y = j;
                    if (X + Y > S) {
                        break;
                    }
                    if (S - X - Y <= K) {
                        count++;
                    }
                }
            }
            System.out.println(count);
        } catch (Exception e) {
            e.printStackTrace();
        }
    } try {
            int K = scanner.nextInt();
            int S = scanner.nextInt();
            int count = 0;
            for (int i = 0; i <= K; i++) {
                int X = i;
                for (int j = 0; j <= K; j++) {
                    int Y = j;
                    if (X + Y > S) {
                        break;
                    }
                    if (S - X - Y <= K) {
                        count++;
                    }
                }
            }
            System.out.println(count);
        } catch (Exception e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        } Exception e {
            e.printStackTrace();
        } e.printStackTrace() e.printStackTrace e {
            int K = scanner.nextInt();
            int S = scanner.nextInt();
            int count = 0;
            for (int i = 0; i <= K; i++) {
                int X = i;
                for (int j = 0; j <= K; j++) {
                    int Y = j;
                    if (X + Y > S) {
                        break;
                    }
                    if (S - X - Y <= K) {
                        count++;
                    }
                }
            }
            System.out.println(count);
        } int K = scanner.nextInt(); K scanner.nextInt() scanner.nextInt scanner int S = scanner.nextInt(); S scanner.nextInt() scanner.nextInt scanner int count = 0; count 0 for (int i = 0; i <= K; i++) {
                int X = i;
                for (int j = 0; j <= K; j++) {
                    int Y = j;
                    if (X + Y > S) {
                        break;
                    }
                    if (S - X - Y <= K) {
                        count++;
                    }
                }
            } int i = 0; int i = 0; i 0 i <= K i K i++ i++ i {
                int X = i;
                for (int j = 0; j <= K; j++) {
                    int Y = j;
                    if (X + Y > S) {
                        break;
                    }
                    if (S - X - Y <= K) {
                        count++;
                    }
                }
            } {
                int X = i;
                for (int j = 0; j <= K; j++) {
                    int Y = j;
                    if (X + Y > S) {
                        break;
                    }
                    if (S - X - Y <= K) {
                        count++;
                    }
                }
            } int X = i; X i for (int j = 0; j <= K; j++) {
                    int Y = j;
                    if (X + Y > S) {
                        break;
                    }
                    if (S - X - Y <= K) {
                        count++;
                    }
                } int j = 0; int j = 0; j 0 j <= K j K j++ j++ j {
                    int Y = j;
                    if (X + Y > S) {
                        break;
                    }
                    if (S - X - Y <= K) {
                        count++;
                    }
                } {
                    int Y = j;
                    if (X + Y > S) {
                        break;
                    }
                    if (S - X - Y <= K) {
                        count++;
                    }
                } int Y = j; Y j if (X + Y > S) {
                        break;
                    } X + Y > S X + Y X Y S {
                        break;
                    } break; if (S - X - Y <= K) {
                        count++;
                    } S - X - Y <= K S - X - Y S - X - Y S X Y K {
                        count++;
                    } count++ count System.out.println(count) System.out.println System.out System System.out count private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
 
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String line = br.readLine();
            while (line.equals("")) {
                line = br.readLine();
            }
            s = line.split(reg, 0);
            i = 0;
            return s[i++];
        }
 
        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }
 
        public double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
 
        public long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }
    } MyScanner String[] s; s int i; i BufferedReader br; br String reg = " "; reg " " MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        } MyScanner {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        } s = new String[0] s new String[0] 0 i = 0 i 0 br = new BufferedReader(new InputStreamReader(System.in)) br new BufferedReader(new InputStreamReader(System.in)) public String next() throws IOException {
            if (i < s.length) return s[i++];
            String line = br.readLine();
            while (line.equals("")) {
                line = br.readLine();
            }
            s = line.split(reg, 0);
            i = 0;
            return s[i++];
        } next {
            if (i < s.length) return s[i++];
            String line = br.readLine();
            while (line.equals("")) {
                line = br.readLine();
            }
            s = line.split(reg, 0);
            i = 0;
            return s[i++];
        } if (i < s.length) return s[i++]; i < s.length i s.length s s.length return s[i++]; s[i++] s i++ i String line = br.readLine(); line br.readLine() br.readLine br while (line.equals("")) {
                line = br.readLine();
            } line.equals("") line.equals line "" {
                line = br.readLine();
            } line = br.readLine() line br.readLine() br.readLine br s = line.split(reg, 0) s line.split(reg, 0) line.split line reg 0 i = 0 i 0 return s[i++]; s[i++] s i++ i public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        } nextInt {
            return Integer.parseInt(next());
        } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next public double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        } nextDouble {
            return Double.parseDouble(next());
        } return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next public long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        } nextLong {
            return Long.parseLong(next());
        } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next public class Main {
    private static MyScanner scanner;
 
    public static void main (String[] args){
        Main instance = new Main();
        scanner = instance.new MyScanner();
        instance.solve();
    }
 
    private void solve() {
        try {
            int K = scanner.nextInt();
            int S = scanner.nextInt();
            int count = 0;
            for (int i = 0; i <= K; i++) {
                int X = i;
                for (int j = 0; j <= K; j++) {
                    int Y = j;
                    if (X + Y > S) {
                        break;
                    }
                    if (S - X - Y <= K) {
                        count++;
                    }
                }
            }
            System.out.println(count);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
 
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String line = br.readLine();
            while (line.equals("")) {
                line = br.readLine();
            }
            s = line.split(reg, 0);
            i = 0;
            return s[i++];
        }
 
        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }
 
        public double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
 
        public long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }
    }
} public class Main {
    private static MyScanner scanner;
 
    public static void main (String[] args){
        Main instance = new Main();
        scanner = instance.new MyScanner();
        instance.solve();
    }
 
    private void solve() {
        try {
            int K = scanner.nextInt();
            int S = scanner.nextInt();
            int count = 0;
            for (int i = 0; i <= K; i++) {
                int X = i;
                for (int j = 0; j <= K; j++) {
                    int Y = j;
                    if (X + Y > S) {
                        break;
                    }
                    if (S - X - Y <= K) {
                        count++;
                    }
                }
            }
            System.out.println(count);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
 
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String line = br.readLine();
            while (line.equals("")) {
                line = br.readLine();
            }
            s = line.split(reg, 0);
            i = 0;
            return s[i++];
        }
 
        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }
 
        public double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
 
        public long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }
    }
} Main
import java.io.*;
import java.util.*;
public class Main {
    private static MyScanner scanner;
 
    public static void main (String[] args){
        Main instance = new Main();
        scanner = instance.new MyScanner();
        instance.solve();
    }
 
    private void solve() {
        try {
            int K = scanner.nextInt();
            int S = scanner.nextInt();
            int count = 0;
            for (int i = 0; i <= K; i++) {
                int X = i;
                for (int j = 0; j <= K; j++) {
                    int Y = j;
                    if (X + Y > S) {
                        break;
                    }
                    if (S - X - Y <= K) {
                        count++;
                    }
                }
            }
            System.out.println(count);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
 
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String line = br.readLine();
            while (line.equals("")) {
                line = br.readLine();
            }
            s = line.split(reg, 0);
            i = 0;
            return s[i++];
        }
 
        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }
 
        public double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
 
        public long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }
    }
}