#include <bits/stdc++.h>
using namespace std;
const int max_n = 100005;
const long long mod = 1000000009;
int n, m, k;
long long pow(long long a, long long b) {
  if (b == 0) return 1;
  long long res = pow(a, b / 2);
  res *= res;
  res %= mod;
  if (b % 2) res *= (long long)a;
  res %= mod;
  return res;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  long long d = (long long)m - (long long)(n / k) * (long long)(k - 1) -
                (long long)(n % k);
  if (d <= 0)
    printf("%d\n", m);
  else {
    long long res = pow(2ll, d + 1ll) - 2ll + mod;
    res %= mod;
    res *= (long long)k;
    res %= mod;
    res += (((n / k) - d) * (k - 1)) % mod;
    res %= mod;
    res += n % k;
    res %= mod;
    cout << res << "\n";
  }
  return 0;
}
