import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int k = Integer.parseInt(str[0]);
        int s = Integer.parseInt(str[1]);
        int ans = 0;
        
        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= k; y++) {
                if (s - x - y >= 0 && s - x - y <= k) ans++;
            }
        }
        
        System.out.println(ans);
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int k = Integer.parseInt(str[0]);
        int s = Integer.parseInt(str[1]);
        int ans = 0;
        
        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= k; y++) {
                if (s - x - y >= 0 && s - x - y <= k) ans++;
            }
        }
        
        System.out.println(ans);
    }
} Main public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int k = Integer.parseInt(str[0]);
        int s = Integer.parseInt(str[1]);
        int ans = 0;
        
        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= k; y++) {
                if (s - x - y >= 0 && s - x - y <= k) ans++;
            }
        }
        
        System.out.println(ans);
    } main {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int k = Integer.parseInt(str[0]);
        int s = Integer.parseInt(str[1]);
        int ans = 0;
        
        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= k; y++) {
                if (s - x - y >= 0 && s - x - y <= k) ans++;
            }
        }
        
        System.out.println(ans);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] str = br.readLine().split(" "); str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int k = Integer.parseInt(str[0]); k Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 int s = Integer.parseInt(str[1]); s Integer.parseInt(str[1]) Integer.parseInt Integer str[1] str 1 int ans = 0; ans 0 for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= k; y++) {
                if (s - x - y >= 0 && s - x - y <= k) ans++;
            }
        } 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 >= 0 && s - x - y <= k) ans++;
            }
        } {
            for (int y = 0; y <= k; y++) {
                if (s - x - y >= 0 && s - x - y <= k) ans++;
            }
        } for (int y = 0; y <= k; y++) {
                if (s - x - y >= 0 && s - x - y <= k) ans++;
            } int y = 0; int y = 0; y 0 y <= k y k y++ y++ y {
                if (s - x - y >= 0 && s - x - y <= k) ans++;
            } {
                if (s - x - y >= 0 && s - x - y <= k) ans++;
            } if (s - x - y >= 0 && s - x - y <= k) ans++; s - x - y >= 0 && s - x - y <= k s - x - y >= 0 s - x - y s - x - y s x y 0 s - x - y <= k s - x - y s - x - y s x y k ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int k = Integer.parseInt(str[0]);
        int s = Integer.parseInt(str[1]);
        int ans = 0;
        
        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= k; y++) {
                if (s - x - y >= 0 && s - x - y <= k) ans++;
            }
        }
        
        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int k = Integer.parseInt(str[0]);
        int s = Integer.parseInt(str[1]);
        int ans = 0;
        
        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= k; y++) {
                if (s - x - y >= 0 && s - x - y <= k) ans++;
            }
        }
        
        System.out.println(ans);
    }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int k = Integer.parseInt(str[0]);
        int s = Integer.parseInt(str[1]);
        int ans = 0;
        
        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= k; y++) {
                if (s - x - y >= 0 && s - x - y <= k) ans++;
            }
        }
        
        System.out.println(ans);
    }
}
