#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

typedef long long s64;

const int MaxN = 2000;
const int MaxM = 2000;
const int M = 1000000007;

inline int add(int a, const int &b)
{
	a += b;
	return a >= M ? a - M : a;
}
inline int dec(int a, const int &b)
{
	a -= b;
	return a < 0 ? a + M : a;
}

int n, m, nK;
int f[MaxN + MaxM][MaxN + 1];

int g[MaxN + 1];

int res = 0;

int main()
{
	cin >> n >> m >> nK;

	int l = (n + m - 1) / --nK;
	int p = n % nK, q = (m - 1) % nK;

	f[0][0] = 1;
	for (int i = 1; i <= l; ++i)
	{
		int now = min(i * nK, n);

		g[0] = f[i - 1][0];
		for (int j = 1; j <= now; ++j)
			g[j] = add(g[j - 1], f[i - 1][j]);

		for (int j = 0; j <= now; ++j)
		{
			int up = min(nK, j);
			int a = up == j ? 0 : g[j - up - 1];
			int b = g[j];
			f[i][j] = dec(b, a);
		}

		for (int j = 0; j <= now; ++j)
		{
			if (j % nK != p || (i * nK - j) % nK != q)
				continue;
			if (i * nK - j < m)
				res = add(res, dec(f[i][j], f[i - 1][j]));
		}
	}

	cout << res << endl;

	return 0;
}