#include <bits/stdc++.h>
using namespace std;
long long ans = 0, n, m, k;
long long solve(long long x) {
  if (x == 0) return 1;
  long long w = solve(x >> 1);
  if (x & 1) return w * w * 2 % 1000000009;
  return w * w % 1000000009;
}
int main() {
  long long i, j, l;
  scanf("%I64d%I64d%I64d", &n, &m, &k);
  if ((n - m) >= n / k)
    printf("%I64d", m);
  else {
    long long p = n - m;
    long long ans;
    ans = solve(m + n / k - n + 1) - 2;
    printf("%I64d\n",
           (ans * k + m - k * (m + n / k - n) + 1000000009) % 1000000009);
  }
  return 0;
}
