from sys import stdin def main(): L, R, M = map(int, input().split()) divl, modl = divmod(L, M) divr, modr = divmod(R, M) if divl and divr: ans = M elif not divl and not divr: ans = R - L else: ans = (M - L + 1) + modr print(ans) input = lambda: stdin.readline() main()