#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const long long mod = 1e9 + 9;
long long ksm(long long a, long long b) {
  long long ans = 1, tem = a;
  while (b) {
    if (b & 1) ans = (ans * tem) % mod;
    tem = (tem * tem) % mod;
    b >>= 1;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  long long n, m, k;
  cin >> n >> m >> k;
  if (n <= k * (n - m)) {
    cout << m << endl;
    return 0;
  }
  long long ans;
  long long blo = n / k - (n - m);
  ans = ((k % mod) * ((ksm(2, blo + 1) - 2 + mod) % mod) % mod +
         (m - blo * k + mod) + mod) %
        mod;
  cout << ans;
  return 0;
}
