x, y, z = map(int, input().split(' ')) ans_list = [] for num in range(x, y+1): if (num % z) not in ans_list: ans_list.append(num % z) elif num % z in ans_list: break print(len(ans_list))