L, R, M = map(int, input().strip().split()) if L//M + R//M <= 1: print(R-L+1) else: print(M)