#include const int Mod = 1000000007; int comb[8001][8001], comb_sum[8001][8001]; long long solve_even(int N, int M) { int i, j; long long ans = 0; for (i = 0; i <= N / 2; i++) { for (j = 0; j < N / 2 && i + j <= M; j++) { if (i + j == 0) continue; ans += (long long)comb_sum[M-1][i+j-1] * comb[N][i] % Mod * comb[N-i][j] % Mod; } } if (M % 2 == 0) ans++; return ans % Mod; } long long solve_odd(int N, int M) { int i, j; long long ans = 0; for (i = 0; i <= N / 2; i++) { for (j = 0; j <= N / 2; j++) { if (i + j == 0) continue; if (i + j <= M) ans += (long long)comb_sum[M-1][i+j-1] * comb[N][i] % Mod * comb[N-i][j] % Mod; if (i <= j) { if (M - N - i + j < 0) continue; ans += (long long)comb_sum[M-N+j*2-1][i+j-1] * comb[N][i] % Mod * comb[N-i][j] % Mod; } else { if (M - N + i - j < 0) continue; ans += (long long)comb_sum[M-N+i*2-1][i+j-1] * comb[N][i] % Mod * comb[N-i][j] % Mod; } } } if (M % 2 == 0 || M >= N) ans++; return ans % Mod; } int main() { int i, j, N, M; scanf("%d %d", &N, &M); for (i = 1, comb[0][0] = 1, comb_sum[0][0] = 1; i <= N + M; i++) { for (j = 1, comb[i][0] = 1, comb[i][i] = 1; j < i; j++) { comb[i][j] = comb[i-1][j-1] + comb[i-1][j]; if (comb[i][j] >= Mod) comb[i][j] -= Mod; } for (j = 0; j <= i; j++) { comb_sum[i][j] = ((i - 2 >= j)? comb_sum[i-2][j]: 0) + comb[i][j]; if (comb_sum[i][j] >= Mod) comb_sum[i][j] -= Mod; } } if (N % 2 == 0) printf("%lld\n", solve_even(N, M)); else printf("%lld\n", solve_odd(N, M)); fflush(stdout); return 0; }