#include <bits/stdc++.h>
int main() {
  int a, b, c, d, e, f;
  d = 0;
  e = 0;
  f = 0;
  scanf("%d %d %d", a, b, c);
  if (a > b) {
    d = a;
    a = b;
    b = d;
  }
  while (a == b) {
    e = a % c;
    if (e == 0) {
      f = f + 1;
    }
    a = a + 1;
  }
  printf("%d", f);
  return 0;
}
