import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
import java.lang.Math.*;
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        HashMap<Integer,Integer> mem = new HashMap<>();
        int k = in.nextInt();
        int s = in.nextInt();
        int x = Math.min(s,k);
        int total=0 ;
        for(int i =0;i<=x;i++){
            for(int j=0;j<=x;j++){
                int sum = i+j;
                if(sum<=s && sum+x>=s)
                    total++;
            }
        }
        System.out.print(total);
    }
} import java.io.InputStream; InputStream java.io import java.io.OutputStream; OutputStream java.io import java.io.PrintWriter; PrintWriter java.io import java.util.*; util.* java import java.lang.Math.*; Math.* java.lang public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        HashMap<Integer,Integer> mem = new HashMap<>();
        int k = in.nextInt();
        int s = in.nextInt();
        int x = Math.min(s,k);
        int total=0 ;
        for(int i =0;i<=x;i++){
            for(int j=0;j<=x;j++){
                int sum = i+j;
                if(sum<=s && sum+x>=s)
                    total++;
            }
        }
        System.out.print(total);
    }
} Main public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        HashMap<Integer,Integer> mem = new HashMap<>();
        int k = in.nextInt();
        int s = in.nextInt();
        int x = Math.min(s,k);
        int total=0 ;
        for(int i =0;i<=x;i++){
            for(int j=0;j<=x;j++){
                int sum = i+j;
                if(sum<=s && sum+x>=s)
                    total++;
            }
        }
        System.out.print(total);
    } main {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        HashMap<Integer,Integer> mem = new HashMap<>();
        int k = in.nextInt();
        int s = in.nextInt();
        int x = Math.min(s,k);
        int total=0 ;
        for(int i =0;i<=x;i++){
            for(int j=0;j<=x;j++){
                int sum = i+j;
                if(sum<=s && sum+x>=s)
                    total++;
            }
        }
        System.out.print(total);
    } InputStream inputStream = System.in; inputStream System.in System System.in OutputStream outputStream = System.out; outputStream System.out System System.out Scanner in = new Scanner(inputStream); in new Scanner(inputStream) PrintWriter out = new PrintWriter(outputStream); out new PrintWriter(outputStream) HashMap<Integer,Integer> mem = new HashMap<>(); mem new HashMap<>() int k = in.nextInt(); k in.nextInt() in.nextInt in int s = in.nextInt(); s in.nextInt() in.nextInt in int x = Math.min(s,k); x Math.min(s,k) Math.min Math s k int total=0 ; total 0 for(int i =0;i<=x;i++){
            for(int j=0;j<=x;j++){
                int sum = i+j;
                if(sum<=s && sum+x>=s)
                    total++;
            }
        } int i =0; int i =0; i 0 i<=x i x i++ i++ i {
            for(int j=0;j<=x;j++){
                int sum = i+j;
                if(sum<=s && sum+x>=s)
                    total++;
            }
        } {
            for(int j=0;j<=x;j++){
                int sum = i+j;
                if(sum<=s && sum+x>=s)
                    total++;
            }
        } for(int j=0;j<=x;j++){
                int sum = i+j;
                if(sum<=s && sum+x>=s)
                    total++;
            } int j=0; int j=0; j 0 j<=x j x j++ j++ j {
                int sum = i+j;
                if(sum<=s && sum+x>=s)
                    total++;
            } {
                int sum = i+j;
                if(sum<=s && sum+x>=s)
                    total++;
            } int sum = i+j; sum i+j i j if(sum<=s && sum+x>=s)
                    total++; sum<=s && sum+x>=s sum<=s sum s sum+x>=s sum+x sum x s total++ total System.out.print(total) System.out.print System.out System System.out total String[] args args public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        HashMap<Integer,Integer> mem = new HashMap<>();
        int k = in.nextInt();
        int s = in.nextInt();
        int x = Math.min(s,k);
        int total=0 ;
        for(int i =0;i<=x;i++){
            for(int j=0;j<=x;j++){
                int sum = i+j;
                if(sum<=s && sum+x>=s)
                    total++;
            }
        }
        System.out.print(total);
    }
} public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        HashMap<Integer,Integer> mem = new HashMap<>();
        int k = in.nextInt();
        int s = in.nextInt();
        int x = Math.min(s,k);
        int total=0 ;
        for(int i =0;i<=x;i++){
            for(int j=0;j<=x;j++){
                int sum = i+j;
                if(sum<=s && sum+x>=s)
                    total++;
            }
        }
        System.out.print(total);
    }
} Main
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
import java.lang.Math.*;
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        HashMap<Integer,Integer> mem = new HashMap<>();
        int k = in.nextInt();
        int s = in.nextInt();
        int x = Math.min(s,k);
        int total=0 ;
        for(int i =0;i<=x;i++){
            for(int j=0;j<=x;j++){
                int sum = i+j;
                if(sum<=s && sum+x>=s)
                    total++;
            }
        }
        System.out.print(total);
    }
}
