inputs = STDIN.readlines.map(&:chomp) x = inputs[0].to_i y = inputs[1].to_i l = inputs[2].to_i def operations(x, y, l) c = x.abs / l + (x % l == 0 ? 0 : 1) + y.abs / l + (y % l == 0 ? 0 : 1) c + case when x == 0 && y >= 0 0 when y >= 0 1 else 2 end end puts operations(x, y, l)