#include <bits/stdc++.h>
using namespace std;
long long int power(long long int a, long long int b) {
  a %= 1000000009;
  long long int res = 1;
  while (b) {
    if (b & 1) {
      res = (res * a) % 1000000009;
    }
    a = (a * a) % 1000000009;
    b >>= 1;
  }
  return res;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long int n, m, k;
  cin >> n >> m >> k;
  long long int l = 0, r = m / k;
  while (l < r) {
    long long int x = (l + r) / 2;
    long long int NN = n - x * k;
    long long int MM = m - x * k;
    if (NN - NN / k >= MM) {
      r = x;
    } else {
      l = x + 1;
    }
  }
  long long int x = l;
  long long int ans = (m - x * k);
  long long int u = (power(2, x + 1) + 1000000009 - 2) % 1000000009;
  ans = (ans + u * k) % 1000000009;
  cout << ans << endl;
}
