#include <bits/stdc++.h>
using namespace std;
vector<long long int> r;
long long int ciclo = 0;
long long int pasos = 0;
inline long long int step() {
  long long int best = 1;
  for (int i = 0; i < (int)(int((r).size())); i++) best = max(best, r[i]);
  for (int i = 0; i < (int)(int((r).size())); i++)
    r[i] = (r[i] - (best % (2 + i)) + 2 + i) % (2 + i);
  ciclo += best;
  pasos++;
  return best;
}
int main() {
  long long int a, b, k;
  cin >> a >> b >> k;
  long long int ao = a;
  for (int m = (int)(2); m < ((int)k + 1); m++) r.push_back(a % m);
  vector<long long int> r2 = r;
  map<vector<long long int>, pair<long long int, long long int> > M;
  M[r] = make_pair(0, 0);
  bool fail = false;
  while (true) {
    if (a - b < ciclo) {
      fail = true;
    }
    step();
    if (M.count(r) == 1) {
      break;
    }
    M[r] = make_pair(ciclo, pasos);
  }
  long long int tciclo = ciclo - M[r].first;
  long long int pasos_ciclo = pasos - M[r].second;
  long long int warmup = M[r].second;
  a -= M[r].first;
  long long int times_ciclos = (a - b) / tciclo;
  long long int total = times_ciclos * pasos_ciclo + warmup;
  a -= times_ciclos * tciclo;
  if (fail) {
    total = 0;
    a = ao;
    r = r2;
  }
  while (true) {
    if (a == b) break;
    long long int best = 1;
    for (int i = 0; i < (int)(int((r).size())); i++)
      if (r[i] <= a - b) best = max(best, r[i]);
    for (int i = 0; i < (int)(int((r).size())); i++)
      r[i] = (r[i] - (best % (2 + i)) + 2 + i) % (2 + i);
    a -= best;
    total++;
  }
  cout << total << endl;
  return 0;
}
