#include <bits/stdc++.h>
using namespace std;
long long twice[66];
int main() {
  twice[1] = 2;
  int m, n, k, p, c;
  long long ans1, ans, ct = 1;
  cin >> n >> m >> k;
  p = n - m;
  for (int i = 2; i < 40; i++)
    twice[i] = (twice[i - 1] * twice[i - 1]) % 1000000009;
  if ((m - 1) / (k - 1) <= p)
    ans = m;
  else {
    m -= p * (k - 1);
    ans1 = p * (k - 1);
    c = m / k;
    m = m % k;
    ans1 += m;
    k = (2 * k) % 1000000009;
    p = 0;
    while (c) {
      p++;
      if (c % 2) {
        ct = (ct * twice[p]) % 1000000009;
      }
      c = c / 2;
    }
    ans = ((ct - 1) * k) % 1000000009;
    ans = (ans + ans1) % 1000000009;
  }
  cout << ans << endl;
  return 0;
}
