#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll dp[5001][2001];
int main()
{
	int n1, n2, gen;
	scanf("%d%d%d", &n1, &n2, &gen);
	dp[0][0] = 1;
	ll ans = 0;
	for (int i = 0; i < (n1 + n2) / (gen - 1); i++)
	{
		for (int j = 0; j <= n1; j++)
		{
			for (int k = 0; k <= gen - 1; k++)
			{
				if (j + k <= n1)
				{
					dp[i + 1][j + k] += dp[i][j];
					dp[i + 1][j + k] %= mod;
				}
			}
			for (int k = 1; k <= gen - 1; k++)
			{
				if (j + k <= n1 && i*(gen - 1) + gen - j - k <= n2 && (n1 - j - k) % (gen - 1) == 0)
				{
					ans += dp[i][j];
					ans %= mod;
				}
			}
		}
	}
	printf("%lld\n", ans);
}