import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int m = scanner.nextInt();
int n = scanner.nextInt();
scanner.close();
System.out.println(divide(n, m));
}
public static int divide(int n, int m) {
int[] arr = new int[m];
for (int i = 0; i < m; i++) {
arr[i] = 1;
}
if (n == m) {
return 1;
}
return backtrack(m, n - m, 0, arr);
}
//通过递归与回溯,计算出在每个员工一个月饼的基础上、符合条件的的全排列所有可能
private static int backtrack(int m, int remaining, int index, int[] arr) {
// 所有员工都分配好了月饼时,看月饼是否分配完
if (index == m) {
if (remaining == 0) {
return 1;
} else {
return 0;
}
}
// 月饼提前分配完,看是否满足差额限制
if (remaining == 0) {
if (index == 0 || (index > 0 && arr[index] >= arr[index - 1] - 3)) {
return 1;
} else {
return 0;
}
}
int result = 0;
// 尝试给当前位置分配从1到remaining的月饼
for (int i = 1; i <= remaining; i++) {
int value = arr[index] + i;
// 检查当前分配是否满足条件
if (index == 0 || (index > 0 && arr[index - 1] >= value && value >= arr[index - 1] - 3)) {
arr[index] += i;
// 递归分配剩余的月饼
result += backtrack(m, remaining - i, index + 1, arr);
// 回溯
arr[index] -= i;
}
}
return result;
}
}