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