#include <bits/stdc++.h>
using namespace std;
const int Inf = (int)1e10;
int gcd(int a, int b) {
  if (b > a) return gcd(b, a);
  while (a % b != 0) {
    int tmp = a % b;
    a = b;
    b = tmp;
  }
  return b;
}
int lcm(int a, int b) {
  int g = gcd(a, b);
  return a * b / g;
}
int main() {
  ios_base::sync_with_stdio(false);
  long long a, b, k;
  cin >> a >> b >> k;
  long long res = 0;
  int period = 1;
  for (int i = 2; i <= k; i++) period = lcm(period, i);
  long long visited[period];
  for (int i = 0; i < period; i++) visited[i] = -1;
  while (visited[a % period] == -1) {
    if (a == b) {
      cout << res;
      return 0;
    }
    visited[a % period] = res;
    long long next = a - 1;
    for (int i = 2; i <= k; i++) {
      long long target = a / i * i;
      if (target >= b) next = min(next, target);
    }
    a = next;
    res++;
  }
  long long periodSize = res - visited[a % period];
  long long periods = (a - b) / period;
  a -= periods * period;
  res += periods * periodSize;
  while (a > b) {
    long long next = a - 1;
    for (int i = 2; i <= k; i++) {
      long long target = a / i * i;
      if (target >= b) next = min(next, target);
    }
    a = next;
    res++;
  }
  cout << res;
}
