import java.util.*;

class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int k = scan.nextInt();
        int s = scan.nextInt();
        int out = 0;
        for(int i = 0; i <= k; i++){
            for(int j = 0; j <= k; j++){
                int z = s - i - j;
                if(0 <= z && z <= k) out++;
            }
        }
        System.out.println(out);
        scan.close();
    }
    
    public static void main(String[] args){
        new Main().solve();
    }
} import java.util.*; util.* java class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int k = scan.nextInt();
        int s = scan.nextInt();
        int out = 0;
        for(int i = 0; i <= k; i++){
            for(int j = 0; j <= k; j++){
                int z = s - i - j;
                if(0 <= z && z <= k) out++;
            }
        }
        System.out.println(out);
        scan.close();
    }
    
    public static void main(String[] args){
        new Main().solve();
    }
} Main void solve(){
        Scanner scan = new Scanner(System.in);
        int k = scan.nextInt();
        int s = scan.nextInt();
        int out = 0;
        for(int i = 0; i <= k; i++){
            for(int j = 0; j <= k; j++){
                int z = s - i - j;
                if(0 <= z && z <= k) out++;
            }
        }
        System.out.println(out);
        scan.close();
    } solve {
        Scanner scan = new Scanner(System.in);
        int k = scan.nextInt();
        int s = scan.nextInt();
        int out = 0;
        for(int i = 0; i <= k; i++){
            for(int j = 0; j <= k; j++){
                int z = s - i - j;
                if(0 <= z && z <= k) out++;
            }
        }
        System.out.println(out);
        scan.close();
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int k = scan.nextInt(); k scan.nextInt() scan.nextInt scan int s = scan.nextInt(); s scan.nextInt() scan.nextInt scan int out = 0; out 0 for(int i = 0; i <= k; i++){
            for(int j = 0; j <= k; j++){
                int z = s - i - j;
                if(0 <= z && z <= k) out++;
            }
        } int i = 0; int i = 0; i 0 i <= k i k i++ i++ i {
            for(int j = 0; j <= k; j++){
                int z = s - i - j;
                if(0 <= z && z <= k) out++;
            }
        } {
            for(int j = 0; j <= k; j++){
                int z = s - i - j;
                if(0 <= z && z <= k) out++;
            }
        } for(int j = 0; j <= k; j++){
                int z = s - i - j;
                if(0 <= z && z <= k) out++;
            } int j = 0; int j = 0; j 0 j <= k j k j++ j++ j {
                int z = s - i - j;
                if(0 <= z && z <= k) out++;
            } {
                int z = s - i - j;
                if(0 <= z && z <= k) out++;
            } int z = s - i - j; z s - i - j s - i - j s i j if(0 <= z && z <= k) out++; 0 <= z && z <= k 0 <= z 0 z z <= k z k out++ out System.out.println(out) System.out.println System.out System System.out out scan.close() scan.close scan public static void main(String[] args){
        new Main().solve();
    } main {
        new Main().solve();
    } new Main().solve() new Main().solve new Main() String[] args args
import java.util.*;

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