l, r, m = map(int, input().split()) print(len({x % m for x in range(l, min(r, l+m)+1)}))