#include <bits/stdc++.h>
using namespace std;
long long k;
long long mas[370000];
long long MAX = 1024LL * 1024LL * 1024LL * 1024LL * 1024LL;
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long r(long long n) {
  if (n < 0) return MAX;
  if (mas[n] != -1) return mas[n];
  long long ans;
  ans = r(n - 1);
  for (int i = 2; i <= k; i++)
    if (n % i && (r(n - n % i) < ans)) ans = mas[n - n % i];
  mas[n] = ans + 1;
  return mas[n];
}
int main() {
  long long a, b;
  long long d;
  cin >> a >> b >> k;
  if (a == b) {
    cout << "0" << endl;
    return 0;
  }
  if (b > a) {
    cout << "-1" << endl;
    return 0;
  }
  if (k == 2) {
    cout << a - b << endl;
    return 0;
  }
  d = 1;
  for (int i = 2; i <= k; i++) d *= (i / gcd(d, i));
  memset(mas, -1, sizeof(mas));
  if (b / d == a / d) {
    a %= d;
    b %= d;
    for (int i = 0; i < b; i++) mas[i] = MAX;
    mas[b] = 0;
    mas[b + 1] = 1;
    cout << r(a) << endl;
    return 0;
  }
  mas[0] = 0;
  for (int i = 1; i < k; i++) mas[i] = 1;
  r(d);
  long long ans = 0;
  ans = mas[a % d] + mas[d] * (a / d - b / d - 1);
  b %= d;
  a = d;
  memset(mas, -1, sizeof(mas));
  for (int i = 0; i < b; i++) mas[i] = MAX;
  mas[b] = 0;
  mas[b + 1] = 1;
  ans += r(a);
  cout << ans << endl;
  return 0;
}
