x = int(input()) y = int(input()) L = int(input()) dx = abs(x) dy = abs(y) min_commands = float('inf') if x == 0 and y == 0: print(0) exit() # Case 1: Y is non-negative (handling north direction) if y >= 0: y_commands = (dy + L - 1) // L if dy != 0 else 0 if x == 0: min_commands = min(min_commands, y_commands) else: # Consider both east and west for x x_commands = (dx + L - 1) // L total = y_commands + x_commands + 1 min_commands = min(min_commands, total) # Case 2: Y is negative (handling south direction) if y <= 0: if dy > 0: y_commands = (dy + L - 1) // L current_total = y_commands + 2 # Turning south (2 commands) if x != 0: x_commands = (dx + L - 1) // L current_total += x_commands + 1 # Turning east or west (1 command) min_commands = min(min_commands, current_total) # Case 3: X is zero (handling Y direction) if x == 0: if y >= 0: commands = (dy + L - 1) // L if dy > 0 else 0 min_commands = min(min_commands, commands) else: commands = ((dy + L - 1) // L + 2) if dy > 0 else 0 min_commands = min(min_commands, commands) # Case 4: Y is zero (handling X direction) if y == 0: if x != 0: commands = (dx + L - 1) // L + 1 # Turn once to east or west min_commands = min(min_commands, commands) print(min_commands)