import java.util.Scanner;
import java.util.Set;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());
        int cnt=0;
        for(int x=0;x<=k;x++){
            for(int y=0;y<=k;y++){
                int z = s-(x+y);
                if(z>=0 && z<=k){cnt++;}
            }
        }
        System.out.println(cnt);
    }
} import java.util.Scanner; Scanner java.util import java.util.Set; Set java.util public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());
        int cnt=0;
        for(int x=0;x<=k;x++){
            for(int y=0;y<=k;y++){
                int z = s-(x+y);
                if(z>=0 && z<=k){cnt++;}
            }
        }
        System.out.println(cnt);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());
        int cnt=0;
        for(int x=0;x<=k;x++){
            for(int y=0;y<=k;y++){
                int z = s-(x+y);
                if(z>=0 && z<=k){cnt++;}
            }
        }
        System.out.println(cnt);
    } main {
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());
        int cnt=0;
        for(int x=0;x<=k;x++){
            for(int y=0;y<=k;y++){
                int z = s-(x+y);
                if(z>=0 && z<=k){cnt++;}
            }
        }
        System.out.println(cnt);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int k = Integer.parseInt(sc.next()); k Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int s = Integer.parseInt(sc.next()); s Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int cnt=0; cnt 0 for(int x=0;x<=k;x++){
            for(int y=0;y<=k;y++){
                int z = s-(x+y);
                if(z>=0 && z<=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 z = s-(x+y);
                if(z>=0 && z<=k){cnt++;}
            }
        } {
            for(int y=0;y<=k;y++){
                int z = s-(x+y);
                if(z>=0 && z<=k){cnt++;}
            }
        } for(int y=0;y<=k;y++){
                int z = s-(x+y);
                if(z>=0 && z<=k){cnt++;}
            } int y=0; int y=0; y 0 y<=k y k y++ y++ y {
                int z = s-(x+y);
                if(z>=0 && z<=k){cnt++;}
            } {
                int z = s-(x+y);
                if(z>=0 && z<=k){cnt++;}
            } int z = s-(x+y); z s-(x+y) s (x+y) x y if(z>=0 && z<=k){cnt++;} z>=0 && z<=k z>=0 z 0 z<=k z k {cnt++;} 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) {
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());
        int cnt=0;
        for(int x=0;x<=k;x++){
            for(int y=0;y<=k;y++){
                int z = s-(x+y);
                if(z>=0 && z<=k){cnt++;}
            }
        }
        System.out.println(cnt);
    }
} public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());
        int cnt=0;
        for(int x=0;x<=k;x++){
            for(int y=0;y<=k;y++){
                int z = s-(x+y);
                if(z>=0 && z<=k){cnt++;}
            }
        }
        System.out.println(cnt);
    }
} Main
import java.util.Scanner;
import java.util.Set;

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