L, R, M = map(int, input().split()) l = [i for i in range(L, R+1)] ans = [i%M for i in l] print(len(set(ans)))