l,r,m = map(int,input().split()) ans = [] for i in range(l,r+1): ans.append(i%m) print(len(set(ans)))