n, k, m = map(int, input().split()) up = 0 down = 0 curr = m while curr <= n: up += n // curr down += (n - k) // curr down += k // curr curr *= m print(max(0, up - down))