#include <bits/stdc++.h>
using namespace std;
int k;
long long go(long long a, long long b) {
  long long res = 0;
  while (a > b) {
    ++res;
    long long mx = 1LL;
    for (int x = (2); x < (k + 1); ++x)
      if (a - a % x >= b) mx = max(mx, a % x);
    a -= mx;
  }
  return res;
}
int main() {
  long long a, b;
  int m = 360360;
  cin >> a >> b >> k;
  long long res = 0;
  if ((a / m) * m > b) {
    res += go(a, (a / m) * m);
    a = (a / m) * m;
  } else {
    res = go(a, b);
    cout << res << endl;
    return 0;
  }
  long long bb = b;
  if (bb % m != 0) bb = (b / m + 1) * m;
  res += (a - bb) / m * go(m, 0);
  res += go(bb, b);
  cout << res << endl;
  return 0;
}
