l, r, m = map(int, input().split()) memo = set() for x in range(l, r + 1): mod = x % m if mod in memo: break else: memo.add(mod) print(len(memo))