#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-12;
const int INF = 999999999;
const int kMaxP = 27397261;
int L, R, P;
bool flag[kMaxP];
vector<int> primes;
void FindPrimes() {
  for (int i = 2; i * i <= kMaxP; ++i)
    if (!flag[i])
      for (int j = i * i; j <= kMaxP; j += i) flag[j] = 1;
  for (int i = 2; i <= kMaxP; ++i)
    if (!flag[i]) primes.push_back(i);
}
int Com(int k, int l, int r) {
  int p = primes[k];
  if (r < p) return 0;
  int res = 0;
  if (l <= p) {
    res = 1;
    l = p + 1;
  }
  l = (l - 1) / p + 1;
  r /= p;
  if (l > r) return res;
  if (p < 73) {
    res += r - l + 1;
    int mask = (1 << k) - 1;
    for (int i = 1; i <= mask; ++i) {
      int v = 1;
      int c = 0;
      bool over = false;
      for (int j = 0; j < k; j++)
        if ((i >> j) & 1) {
          if (primes[j] > r / v) {
            over = true;
            break;
          }
          v *= primes[j];
          ++c;
        }
      if (over) continue;
      int l2 = (l - 1) / v + 1, r2 = r / v;
      int w = r2 - l2 + 1;
      if (c & 1)
        res -= w;
      else
        res += w;
    }
  } else {
    for (int i = k; i < int((primes).size()) && primes[i] <= r; ++i)
      res += Com(i, l, r);
  }
  return res;
}
int Solve() {
  for (int i = 0;
       i < int((primes).size()) && (long long)primes[i] * primes[i] <= P; ++i) {
    if (P % primes[i] == 0) return 0;
  }
  if ((long long)P * P > R) {
    if (P >= L && P <= R) return 1;
    return 0;
  }
  int k;
  for (k = 0; primes[k] != P; ++k)
    ;
  return Com(k, L, R);
}
int main() {
  FindPrimes();
  scanf("%d%d%d", &L, &R, &P);
  printf("%d\n", Solve());
  return 0;
}
