#include <iostream>
#include <vector>
#include <cassert>
#include <cmath>

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 4000;
int const modulo = 1000000007;

int dp[5 + nmax][5 + nmax];
int sum[5 + nmax][5 + nmax];

int main() {
  int n, m, k;
  std::cin >> n >> m >> k;
  for(int i = 1;i < k; i++)
    dp[1][i] = 1;
  for(int i = 1;i <= m;i++)
    sum[1][i] = sum[1][i - 1] + dp[1][i];
  for(int i = 2; i <= (n + m - 1) / (k - 1); i++) {
    for(int j = 1; j <= m; j++){
      dp[i][j] = sum[i - 1][j];
      if(k <= j)
        dp[i][j] -= sum[i - 1][j - k];
      if(dp[i][j] < 0)
        dp[i][j] += modulo;
    }
    for(int j = 1;j <= m; j++) {
      sum[i][j] = sum[i][j - 1] + dp[i][j];
      if(modulo <= sum[i][j])
        sum[i][j] -= modulo;
    }
  }
  int result = 0;
  for(int i = n; 1 <= i; i -= (k - 1))
    for(int j = m; 1 <= j; j -= (k - 1)) {
      result += dp[(i + j - 1) / (k - 1)][j];
      if(modulo <= result)
        result -= modulo;
    }
  std::cout << result;
  return 0;
}
