import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();

        int l = Math.min(s, k);
        int total = 0;
        for (int i = l; i >= 0; i--) {
            int m = Math.min(s - i, k);
            if (s - i < k) {
                total += m + 1;
            } else {
                total += Math.max(k - (s - i - m) + 1, 0);
            }
        }
        System.out.println(total);
    }
} import java.util.Scanner; Scanner 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 l = Math.min(s, k);
        int total = 0;
        for (int i = l; i >= 0; i--) {
            int m = Math.min(s - i, k);
            if (s - i < k) {
                total += m + 1;
            } else {
                total += Math.max(k - (s - i - m) + 1, 0);
            }
        }
        System.out.println(total);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();

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

        int l = Math.min(s, k);
        int total = 0;
        for (int i = l; i >= 0; i--) {
            int m = Math.min(s - i, k);
            if (s - i < k) {
                total += m + 1;
            } else {
                total += Math.max(k - (s - i - m) + 1, 0);
            }
        }
        System.out.println(total);
    } 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 l = Math.min(s, k); l Math.min(s, k) Math.min Math s k int total = 0; total 0 for (int i = l; i >= 0; i--) {
            int m = Math.min(s - i, k);
            if (s - i < k) {
                total += m + 1;
            } else {
                total += Math.max(k - (s - i - m) + 1, 0);
            }
        } int i = l; int i = l; i l i >= 0 i 0 i-- i-- i {
            int m = Math.min(s - i, k);
            if (s - i < k) {
                total += m + 1;
            } else {
                total += Math.max(k - (s - i - m) + 1, 0);
            }
        } {
            int m = Math.min(s - i, k);
            if (s - i < k) {
                total += m + 1;
            } else {
                total += Math.max(k - (s - i - m) + 1, 0);
            }
        } int m = Math.min(s - i, k); m Math.min(s - i, k) Math.min Math s - i s i k if (s - i < k) {
                total += m + 1;
            } else {
                total += Math.max(k - (s - i - m) + 1, 0);
            } s - i < k s - i s i k {
                total += m + 1;
            } total += m + 1 total m + 1 m 1 {
                total += Math.max(k - (s - i - m) + 1, 0);
            } total += Math.max(k - (s - i - m) + 1, 0) total Math.max(k - (s - i - m) + 1, 0) Math.max Math k - (s - i - m) + 1 k - (s - i - m) k (s - i - m) s - i - m s i m 1 0 System.out.println(total) System.out.println System.out System System.out total 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 l = Math.min(s, k);
        int total = 0;
        for (int i = l; i >= 0; i--) {
            int m = Math.min(s - i, k);
            if (s - i < k) {
                total += m + 1;
            } else {
                total += Math.max(k - (s - i - m) + 1, 0);
            }
        }
        System.out.println(total);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();

        int l = Math.min(s, k);
        int total = 0;
        for (int i = l; i >= 0; i--) {
            int m = Math.min(s - i, k);
            if (s - i < k) {
                total += m + 1;
            } else {
                total += Math.max(k - (s - i - m) + 1, 0);
            }
        }
        System.out.println(total);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();

        int l = Math.min(s, k);
        int total = 0;
        for (int i = l; i >= 0; i--) {
            int m = Math.min(s - i, k);
            if (s - i < k) {
                total += m + 1;
            } else {
                total += Math.max(k - (s - i - m) + 1, 0);
            }
        }
        System.out.println(total);
    }
}
