#include <cstdio>
#define LL long long
const int mod = 5000011;
LL qmi(LL a, int b) {
LL res = 1;
while (b) {
if (b & 1)
res = res * a % mod;
a = a * a % mod;
b >>= 1;
}
return res;
}
LL C(LL a, LL b) {
if (a < b)
return 0;
LL x = 1, y = 1;
for (int i = a, j = 1; j <= b; j ++, i --)
x = x * i % mod, y = y * j % mod;
return x * qmi(y, mod - 2) % mod;
}
int main() {
int n, k;
LL ans = 1;
scanf("%d %d", &n, &k);
for (int i = 1; i + (i - 1) * k <= n; i ++)
ans += C(n - (i - 1) * k, i), ans %= mod;
printf("%lld", ans);
return 0;
}