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