#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  if (b == 0) return 1ll;
  if (b == 1) return a % 1000000009;
  long long l = power(a, b / 2) % 1000000009;
  l = l * l % 1000000009;
  if (b % 2 == 0)
    return l;
  else
    return (l * a) % 1000000009;
}
int main() {
  long long n, m, k;
  cin >> n >> m >> k;
  if (m < k) {
    cout << m << endl;
    return 0;
  }
  long long wrong = n - m;
  long long num = (m / (k - 1));
  if (wrong >= num) {
    cout << m << endl;
    return 0;
  }
  long long ret = (wrong) * (k - 1) % 1000000009;
  m -= (wrong * (k - 1));
  if (m < k) {
    ret += m;
    ret %= 1000000009;
    cout << ret << endl;
  } else {
    ret += (m % k);
    ret %= 1000000009;
    m -= (m % k);
    long long v = (power(2, (m / k) + 1) - 2) % 1000000009;
    v += 1000000009;
    v %= 1000000009;
    ret = ret + (k * v) % 1000000009;
    ret %= 1000000009;
    cout << ret << endl;
  }
}
