X, Y, L = [gets, gets, gets].map(&:to_i) order_count = 0 unless X.zero? div, mod = X.divmod(L) order_count += (div.abs + (mod.zero? ? 0 : 1)) end unless Y.zero? div, mod = Y.divmod(L) order_count += (div.abs + (mod.zero? ? 0 : 1)) end order_count += 1 if !X.zero? && !Y.zero? puts order_count