#include <bits/stdc++.h>
using namespace std;
long long n, m, k, ans, mod = 1e9 + 9;
long long qwe(long long x, long long y) {
  long long ans = 1LL;
  while (y != 0) {
    if (y & 1) ans = (ans * x + mod) % mod;
    y = y / 2;
    x = (x * x + mod) % mod;
  }
  ans = (ans + mod) % mod;
  return ans;
}
int main() {
  scanf("%lld %lld %lld", &n, &m, &k);
  int fal = n - m, div = n / k;
  if (fal >= div)
    printf("%lld\n", (m + mod) % mod);
  else {
    int x = div - fal;
    ans = ((2 * k * (qwe(2LL, x) - 1) + mod) % mod + m - (x * k) + mod) % mod;
    printf("%lld\n", ans);
  }
  return 0;
}
