#include<bits/stdc++.h>
#define ll long long
#define ljc 1000000007
using namespace std;
#define gc getchar
inline ll read(){
    register ll x=0,f=1;char ch=gc();
    while (!isdigit(ch)){if (ch=='-') f=-1;ch=gc();}
    while (isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=gc();}
    return (f==1)?x:-x;
}
int n,m,K;
// f[i][j][0/1] i*(k-1)+1-n<=j<=m
ll f[4004][4004][2],S[4040];
signed main(){
	n=read(),m=read(),K=read();
	f[0][0][0]=1;
	for (int i=1;i<=max(n,m)*2;i++){
		S[0]=(f[i-1][0][0]+f[i-1][0][1])%ljc;
		for (int j=1;j<=max(n,m);j++) S[j]=(S[j-1]+f[i-1][j][0]+f[i-1][j][1])%ljc;
		for (int j=0;j<=max(n,m);j++){
			f[i][j][0]=(f[i-1][j][0]+f[i-1][j][1])%ljc;
			f[i][j][1]=(f[i][j][1]+S[j-1]-(j>=K?S[j-K]:0)+ljc)%ljc;
		}
	}
	ll _=0;
	for (int i=1;i<=max(n,m)*2;i++){
		for (int j=0;j<=max(n,m);j++){
			if (j%(K-1)==m%(K-1)&&j<=m&&j>=i*(K-1)+1-n) _=(_+f[i][j][1])%ljc;
		}
	}
	cout<<_;
	return 0;
}

