import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();
        int ans = 0;
        for (int i = 0; i <= Math.min(s, k); i++) {
            ans += Math.max(0, Math.min(s-i+1, k+1)-Math.max(0,s-i-k));
        }

        System.out.println(ans);
    }

} import java.util.*; util.* java public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();
        int ans = 0;
        for (int i = 0; i <= Math.min(s, k); i++) {
            ans += Math.max(0, Math.min(s-i+1, k+1)-Math.max(0,s-i-k));
        }

        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();
        int ans = 0;
        for (int i = 0; i <= Math.min(s, k); i++) {
            ans += Math.max(0, Math.min(s-i+1, k+1)-Math.max(0,s-i-k));
        }

        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();
        int ans = 0;
        for (int i = 0; i <= Math.min(s, k); i++) {
            ans += Math.max(0, Math.min(s-i+1, k+1)-Math.max(0,s-i-k));
        }

        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 int ans = 0; ans 0 for (int i = 0; i <= Math.min(s, k); i++) {
            ans += Math.max(0, Math.min(s-i+1, k+1)-Math.max(0,s-i-k));
        } int i = 0; int i = 0; i 0 i <= Math.min(s, k) i Math.min(s, k) Math.min Math s k i++ i++ i {
            ans += Math.max(0, Math.min(s-i+1, k+1)-Math.max(0,s-i-k));
        } {
            ans += Math.max(0, Math.min(s-i+1, k+1)-Math.max(0,s-i-k));
        } ans += Math.max(0, Math.min(s-i+1, k+1)-Math.max(0,s-i-k)) ans Math.max(0, Math.min(s-i+1, k+1)-Math.max(0,s-i-k)) Math.max Math 0 Math.min(s-i+1, k+1)-Math.max(0,s-i-k) Math.min(s-i+1, k+1) Math.min Math s-i+1 s-i s i 1 k+1 k 1 Math.max(0,s-i-k) Math.max Math 0 s-i-k s-i-k s i k 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) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();
        int ans = 0;
        for (int i = 0; i <= Math.min(s, k); i++) {
            ans += Math.max(0, Math.min(s-i+1, k+1)-Math.max(0,s-i-k));
        }

        System.out.println(ans);
    }

} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();
        int ans = 0;
        for (int i = 0; i <= Math.min(s, k); i++) {
            ans += Math.max(0, Math.min(s-i+1, k+1)-Math.max(0,s-i-k));
        }

        System.out.println(ans);
    }

} Main
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();
        int ans = 0;
        for (int i = 0; i <= Math.min(s, k); i++) {
            ans += Math.max(0, Math.min(s-i+1, k+1)-Math.max(0,s-i-k));
        }

        System.out.println(ans);
    }

}