#include <bits/stdc++.h>
using namespace std;
long long expo(long long a, long long b) {
  long long r = 1;
  while (b) {
    if (b & 1) r = (r * a) % 1000000009LL;
    a = (a * a) % 1000000009LL;
    b >>= 1LL;
  }
  return r;
}
int main() {
  long long n, m, k;
  cin >> n >> m >> k;
  if ((n / k) * (k - 1) + n % k >= m)
    cout << m << endl;
  else {
    long long q = m - ((n / k) * (k - 1) + n % k);
    long long r =
        ((2LL * (expo(2, q) - 1LL) % 1000000009LL) * k) % 1000000009LL +
        (m - q * k);
    cout << r % 1000000009LL << endl;
  }
  return 0;
}
