#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);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
int k;
int DP[360365];
long long dist;
long long beg;
int solve(int diff) {
  long long num = beg - diff;
  if (num == dist) return 0;
  if (num < dist) return 2000000000;
  if (DP[diff] != -1) return DP[diff];
  int res = solve(diff + 1) + 1;
  for (int i = 2; i <= k; i++) {
    long long nxt = num - (num % i);
    if (nxt == num) continue;
    res = min(res, solve(beg - nxt) + 1);
  }
  DP[diff] = res;
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  long long a, b;
  cin >> a >> b >> k;
  int num = 1;
  for (int i = 2; i <= k; i++) num = lcm(num, i);
  memset(DP, -1, sizeof(DP));
  if (num >= a - b) {
    dist = b;
    beg = a;
    cout << solve(0);
    return 0;
  }
  dist = a;
  while (dist % num) dist--;
  beg = a;
  long long res = solve(0);
  memset(DP, -1, sizeof(DP));
  a = dist;
  dist -= num;
  if (dist <= b) {
    dist = b;
    beg = a;
    res += solve(0);
    cout << res;
    return 0;
  }
  beg = a;
  int tmp = solve(0);
  long long sol = (a - b) / num;
  a -= sol * num;
  res += sol * 1LL * tmp;
  dist = b;
  beg = a;
  memset(DP, -1, sizeof(DP));
  res += solve(0);
  cout << res;
  return 0;
}
