l,r,m = map(int,input().split()) cnt = 0 ans = [] for i in range(l,r+1): t = i%m if not t in ans: cnt += 1 ans.append(t) print(cnt)