X = int(input())
Y = int(input())
L = int(input())

if X == 0 and Y == 0:
    print(0)
    exit()

D_x = abs(X)
D_y = abs(Y)

X_dir_num = 1 if X >= 0 else 3  # 1 for East, 3 for West
Y_dir_num = 0 if Y >= 0 else 2  # 0 for North, 2 for South

x_commands = (D_x + L - 1) // L
y_commands = (D_y + L - 1) // L

def get_rotation_cost(current, target):
    diff = (target - current) % 4
    return min(diff, 4 - diff)

# Case 1: Y first, then X
case1_rot = 0
if D_x != 0:
    if D_y == 0:
        # Rotate from North to X_dir_num
        case1_rot = get_rotation_cost(0, X_dir_num)
    else:
        # Rotate from Y_dir_num to X_dir_num
        case1_rot = get_rotation_cost(Y_dir_num, X_dir_num)
case1 = y_commands + case1_rot + x_commands

# Case 2: X first, then Y
case2_rot1 = 0
if D_x != 0:
    case2_rot1 = get_rotation_cost(0, X_dir_num)

case2_rot2 = 0
if D_y != 0:
    if D_x != 0:
        case2_rot2 = get_rotation_cost(X_dir_num, Y_dir_num)
    else:
        # Current direction is North (0), rotate to Y_dir_num
        case2_rot2 = get_rotation_cost(0, Y_dir_num)

case2 = x_commands + case2_rot1 + y_commands + case2_rot2

print(min(case1, case2))