#include <bits/stdc++.h>
using namespace std;
class node {
 public:
  long long int second;
  long long int length;
};
long long int power(long long int n, long long int k) {
  long long int result = 1;
  while (k > 0) {
    if (k % 2 == 1) result = (result * n) % 1000000009;
    n = (n * n) % 1000000009;
    k = k / 2;
  }
  return result;
}
int main() {
  long long int n, m, k;
  cin >> n >> m >> k;
  long long int val = n / k;
  long long int ans = 0;
  long long int z = m - (n - val);
  val = z;
  if (val < 0) val = 0;
  long long int r =
      (((power(2, val + 1) - 2) * k) % 1000000009 + m - val * k) % 1000000009;
  if (r < 0) r += 1000000009;
  cout << r << endl;
  return 0;
}
