#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000009;
long long twopow(long long x) {
  long long a = 2, ans = 1;
  while (x) {
    if (x & 1) {
      ans *= a;
      ans %= MOD;
    }
    a = (a * a) % MOD;
    x /= 2;
  }
  return ans;
}
int main() {
  long long n, m, k;
  cin >> n >> m >> k;
  long long mm = m;
  m = n - m;
  n -= m * k;
  if (n <= 0) {
    cout << mm;
    return 0;
  }
  long long p = n / k;
  long long x = twopow(p + 1);
  x -= 2;
  if (x < 0) x += MOD;
  x *= k;
  x %= MOD;
  x += n % k + (k - 1) * m;
  x %= MOD;
  cout << x;
  cin >> x;
  return 0;
}
