#include <bits/stdc++.h>
using namespace std;
long long n, m, k, doub;
long long longseg, powers, steps;
const long long MOD = 1000000009;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= MOD;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % MOD;
    a = a * a % MOD;
  }
  return res;
}
long long solve() {
  doub = max(0LL, m - (n / k) * (k - 1) - n % k);
  long long soln;
  if (doub == 0) {
    soln = 0;
  } else {
    long long coeff_k = powmod(2, doub + 1) - 2;
    soln = (coeff_k * k) % MOD;
  }
  return (soln + m - doub * k + MOD) % MOD;
}
int main() {
  cin >> n >> m >> k;
  cout << solve() << endl;
  return 0;
}
