import java.io.*;
import java.util.*;
public class Main {
    public static void main(String args[]) throws Exception {
        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++) {
                if(s - x - y <= k && s - x - y >= 0)
                    cnt++;
            }
        }

        System.out.println(cnt);
    }
} import java.io.*; io.* java import java.util.*; util.* java public class Main {
    public static void main(String args[]) throws Exception {
        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++) {
                if(s - x - y <= k && s - x - y >= 0)
                    cnt++;
            }
        }

        System.out.println(cnt);
    }
} Main public static void main(String args[]) throws Exception {
        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++) {
                if(s - x - y <= k && s - x - y >= 0)
                    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++) {
                if(s - x - y <= k && s - x - y >= 0)
                    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++) {
                if(s - x - y <= k && s - x - y >= 0)
                    cnt++;
            }
        } int x = 0; int x = 0; x 0 x <= k x k x++ x++ x {
            for(int y = 0; y <= k; y++) {
                if(s - x - y <= k && s - x - y >= 0)
                    cnt++;
            }
        } {
            for(int y = 0; y <= k; y++) {
                if(s - x - y <= k && s - x - y >= 0)
                    cnt++;
            }
        } for(int y = 0; y <= k; y++) {
                if(s - x - y <= k && s - x - y >= 0)
                    cnt++;
            } int y = 0; int y = 0; y 0 y <= k y k y++ y++ y {
                if(s - x - y <= k && s - x - y >= 0)
                    cnt++;
            } {
                if(s - x - y <= k && s - x - y >= 0)
                    cnt++;
            } if(s - x - y <= k && s - x - y >= 0)
                    cnt++; s - x - y <= k && s - x - y >= 0 s - x - y <= k s - x - y s - x - y s x y k s - x - y >= 0 s - x - y s - x - y s x y 0 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 k = sc.nextInt();
        int s = sc.nextInt();
        int cnt = 0;
        for(int x = 0; x <= k; x++) {
            for(int y = 0; y <= k; y++) {
                if(s - x - y <= k && s - x - y >= 0)
                    cnt++;
            }
        }

        System.out.println(cnt);
    }
} public class Main {
    public static void main(String args[]) throws Exception {
        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++) {
                if(s - x - y <= k && s - x - y >= 0)
                    cnt++;
            }
        }

        System.out.println(cnt);
    }
} Main
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String args[]) throws Exception {
        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++) {
                if(s - x - y <= k && s - x - y >= 0)
                    cnt++;
            }
        }

        System.out.println(cnt);
    }
}