#include <bits/stdc++.h>
using namespace std;
long long work(long long q) {
  long long res = 1, a = 2;
  while (q) {
    if (q & 1) {
      res = (res * a) % 1000000009;
    }
    a = (a * a) % 1000000009;
    q /= 2;
  }
  return res;
}
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  if (n / k <= n - m) {
    printf("%d\n", m);
  } else {
    long long t = (n - (n - m) * k) / k;
    long long ans = 0;
    ans = (((work(t) - 1 + 1000000009) % 1000000009) * 2 * k) % 1000000009;
    ans = (ans + m - t * k) % 1000000009;
    printf("%I64d\n", ans);
  }
  return 0;
}
