#include<bits/stdc++.h>
using namespace std;
const int maxn=4e3+1;
const int q=1e9+7;
inline int Plus(int x,int y) {return (x+=y)>=q?x-q:x;}
inline void Pe(int &x,int y) {x=Plus(x,y);}
int n,m,k,l,mk,ans=0,f[maxn][maxn];
int main() {
	cin>>n>>m>>k,l=(n+m-1)/(k-1);
	mk=m%(k-1);
	for (int i=1;i<k;++i) f[1][i]=1;
	for (int i=2;i<=l;++i) for (int j=1;j<=m;++j) for (int x=0;x<k && x<=j;++x) Pe(f[i][j],f[i-1][j-x]);
	for (int i=1;i<=l;++i) for (int j=1;j<=m;++j) if (j%(k-1)==mk && (k-1)*i-j<n) Pe(ans,f[i][j]);
	cout<<ans<<endl;
	return 0;
}
