#include <bits/stdc++.h>
using namespace std;
void err(istringstream *iss) {}
template <typename T, typename... Args>
void err(istringstream *iss, const T &varVal, const Args &...args) {
  string varName;
  *iss >> varName;
  if (varName.back() == ',') varName.back() = ' ';
  cout << varName << " = " << varVal << "; ", err(iss, args...);
}
int n, m, K, T, Q, cn;
int lcm[] = {0,   1,    2,    6,     12,    60,     60,     420,
             840, 2520, 2520, 27720, 27720, 360360, 360360, 360360};
long long a, b;
long long func(long long hi, long long lo) {
  long long ret = 0;
  while (hi > lo) {
    long long mx = 1;
    for (int i = 2; i <= K; i++) {
      if (hi % i <= hi - lo) mx = max(mx, hi % i);
    }
    hi -= mx;
    ret++;
  }
  return ret;
}
int main() {
  cin.tie(NULL);
  scanf("%lld%lld%d", &a, &b, &K);
  int l = lcm[K];
  long long x = ((b - 1) / l + 1) * l, y = a / l * l;
  printf("%lld\n", a - b <= l ? func(a, b)
                              : func(x, b) + (y / l - x / l) * func(x + l, x) +
                                    func(a, y));
  return 0;
}
