#include <bits/stdc++.h>
using namespace ::std;
long long gcd(long long a, long long b) {
  if (!b) return a;
  return gcd(b, a % b);
}
inline long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
int main() {
  long long a, b, k, m = 2, step = 1, tot, q;
  cin >> a >> b >> k;
  for (long long i = 3; i <= k; i++) m = lcm(m, i);
  for (long long x = m - 1, mx, i; x > 0; x -= mx, step++)
    for (i = k, mx = 0; i >= 2 && mx < i - 1; i--) mx = max(mx, x % i);
  q = (a - b) / m;
  tot = q * step;
  for (long long x = a - q * m, mx, i; x > b; x -= (mx ? mx : 1), tot++)
    for (i = k, mx = 0; i >= 2 && mx < i - 1; i--)
      if (x - x % i >= b) mx = max(mx, x % i);
  cout << tot << endl;
  return 0;
}
