x = int(input()) y = int(input()) d = int(input()) y1, y2 = divmod(y, d) x1, x2 = divmod(x, d) if y > 0 and y1 < 0: y1 = 0 if x > 0 and x1 < 0: x1 = 0 if y2 != 0: y2 = 1 if x2 != 0: x2 = 1 z = abs(y1) + y2 + abs(x1) + x2 if y > 0 and x != 0: z += 1 elif y < 0: z += 2 print(z)