#include <bits/stdc++.h>
using namespace std;
long long a, b, k;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
long long prim(long long a, long long b) {
  long long x = a;
  long long cnt = 0;
  while (x > b) {
    long long m = 1;
    for (long long i = 2; i <= k; i++) {
      if ((x % i) <= x - b) m = max(m, x % i);
    }
    x -= m;
    cnt++;
  }
  return cnt;
}
int main() {
  cin >> a >> b >> k;
  long long L = 1;
  for (long long i = 2; i <= k; i++) L = lcm(L, i);
  long long L1 = a - (a % L);
  long long L2 = b - (b % L);
  if (b % L) L2 += L;
  if (L2 <= L1) {
    cout << prim(a, L1) + (L1 - L2) / L * prim(L, 0) + prim(L2, b) << endl;
  } else {
    cout << prim(a, b) << endl;
  }
  return 0;
}
