import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        long ans = 0;
        for(int x=Math.max(0,S-2*K);x<=Math.min(K,S);x++){
            int left = S-x;
            ans += Math.min(K,left)-Math.max(0,left-K)+1;
        }
        System.out.println(ans);
    }
} import java.util.*; util.* java class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        long ans = 0;
        for(int x=Math.max(0,S-2*K);x<=Math.min(K,S);x++){
            int left = S-x;
            ans += Math.min(K,left)-Math.max(0,left-K)+1;
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        long ans = 0;
        for(int x=Math.max(0,S-2*K);x<=Math.min(K,S);x++){
            int left = S-x;
            ans += Math.min(K,left)-Math.max(0,left-K)+1;
        }
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        long ans = 0;
        for(int x=Math.max(0,S-2*K);x<=Math.min(K,S);x++){
            int left = S-x;
            ans += Math.min(K,left)-Math.max(0,left-K)+1;
        }
        System.out.println(ans);
    } 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 long ans = 0; ans 0 for(int x=Math.max(0,S-2*K);x<=Math.min(K,S);x++){
            int left = S-x;
            ans += Math.min(K,left)-Math.max(0,left-K)+1;
        } int x=Math.max(0,S-2*K); int x=Math.max(0,S-2*K); x Math.max(0,S-2*K) Math.max Math 0 S-2*K S 2*K 2 K x<=Math.min(K,S) x Math.min(K,S) Math.min Math K S x++ x++ x {
            int left = S-x;
            ans += Math.min(K,left)-Math.max(0,left-K)+1;
        } {
            int left = S-x;
            ans += Math.min(K,left)-Math.max(0,left-K)+1;
        } int left = S-x; left S-x S x ans += Math.min(K,left)-Math.max(0,left-K)+1 ans Math.min(K,left)-Math.max(0,left-K)+1 Math.min(K,left)-Math.max(0,left-K) Math.min(K,left) Math.min Math K left Math.max(0,left-K) Math.max Math 0 left-K left K 1 System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        long ans = 0;
        for(int x=Math.max(0,S-2*K);x<=Math.min(K,S);x++){
            int left = S-x;
            ans += Math.min(K,left)-Math.max(0,left-K)+1;
        }
        System.out.println(ans);
    }
}
