#include <bits/stdc++.h>
using namespace std;
long long bigmod(long long b, long long p, long long m) {
  if (p == 0) return 1;
  if (p % 2 == 0) {
    long long temp = bigmod(b, p / 2, m);
    return (temp * temp) % m;
  }
  return (bigmod(b, p - 1, m) * (b % m)) % m;
}
int main() {
  long long n, m, k;
  cin >> n >> m >> k;
  if (!m) return cout << 0, 0;
  long long ans, l, c = 0;
  c = (m - (n - m) * (k - 1)) / k;
  if (c >= 0) {
    ans = ((bigmod(2, c, 1000000009) - 1) * k * 2) % 1000000009;
    cout << (ans + (m - (c * k))) % 1000000009 << endl;
  } else
    cout << m;
  return 0;
}
