#include <bits/stdc++.h>
using namespace std;
long long b, a, r;
int k;
int d0[360360 + 5], d1[360360 + 5];
void sim() {
  assert(a <= b);
  while (b > a) {
    long long w = b - 1;
    for (int i = 2, ThxDem = k + 1; i < ThxDem; ++i)
      if (b / i * i >= a) w = min(w, b / i * i);
    b = w;
    r++;
  }
}
int main() {
  scanf("%lld%lld%d", &b, &a, &k);
  memset(d0, -1, sizeof(d0));
  d0[b % 360360] = d1[b % 360360] = 0;
  while (1) {
    long long w = b - 1;
    for (int i = 2, ThxDem = k + 1; i < ThxDem; ++i) w = min(w, b / i * i);
    if (w <= a) {
      sim();
      break;
    }
    if (d0[w % 360360] >= 0) {
      int l0 = d0[b % 360360] - d0[w % 360360] + 1,
          l1 = d1[b % 360360] - d1[w % 360360] + b - w;
      long long nc = (w - a) / l1;
      r += nc * l0;
      b -= nc * l1;
      sim();
      break;
    }
    d0[w % 360360] = d0[b % 360360] + 1;
    d1[w % 360360] = d1[b % 360360] + b - w;
    b = w;
    r++;
  }
  printf("%lld\n", r);
  return 0;
}
