#include <bits/stdc++.h>
using namespace std;
const long long mod = (long long)1e9 + 9;
long long Pow(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ans;
}
int main() {
  long long n, m, k;
  while (cin >> n >> m >> k) {
    long long x = n - m;
    long long res = n - k * x;
    long long all;
    if (res / k > 0)
      all = k % mod * (Pow(2, res / k + 1) - 2 + mod) % mod + res % k;
    else
      all = res;
    all %= mod;
    long long cur = x * (k - 1) % mod;
    all += cur;
    cout << (all % mod + mod) % mod << endl;
  }
  return 0;
}
