// yukicoder: No.834 Random Walk Trip // bal4u 2019.8.14 #include typedef long long ll; #define MOD 1000000007 #define MAX 1000005 int fact[MAX+2] = {1,1}; int inv[MAX+2] = {1,1}; int factinv[MAX+2] = {1,1}; int comb(int n, int k) { // if (n < 0 || k < 0 || n < k) return 0; if (k == 0) return 1; return ((((ll)fact[n] * factinv[k]) % MOD) * factinv[n-k]) % MOD; } int main() { int i, N, M, ans; scanf("%d%d", &N, &M); if (N == 1) { puts("1"); return 0; } for (i = 2; i <= M; i++) { fact[i] = (ll)fact[i-1]*i % MOD; inv[i] = -(MOD/i)*(ll)inv[MOD%i] % MOD; factinv[i] = (ll)factinv[i-1]*inv[i] % MOD; } ans = 0; i = (M >> 1) % N; while (i <= M) { ans = (ans + comb(M, i)) % MOD; i += N; } if (ans < 0) ans += MOD; printf("%d\n", ans); return 0; }