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