def count_prog(start, end, prog): distance = end - start if distance < 0: distance *= -1 if distance % prog == 0: count = distance // prog else: count = (distance // prog) + 1 return count (TARGET_X) = int(input().rstrip()) (TARGET_Y) = int(input().rstrip()) (MAX_PROG) = int(input().rstrip()) nof_ope = 0 # 回転する回数を数える # ---Y--- # |+|0|-| # |+|1|1|2| # X0|0|-|2| # |-|1|1|2| if TARGET_Y < 0: nof_ope += 2 elif TARGET_Y == 0: nof_ope += 1 elif TARGET_X != 0: nof_ope += 1 # 南北の移動回数を求める nof_ope += count_prog(0, TARGET_Y, MAX_PROG) # 東西の移動回数を求める nof_ope += count_prog(0, TARGET_X, MAX_PROG) print(nof_ope)