ans' (f:t:_) =
  let rf = f `mod` 2
      df = f `div` 2
      rt = t `mod` 2
      dt = t `div` 2
  in
    if f == t
    then 0
    else if rf == rt
         then ans' [ df, dt ]
         else if rf == 0
              then 1 + (ans' [df, dt])
              else 1 + (ans' [df + 1, dt])

ans (f:t:_) =
  if (f < 0) && (t > 0)
  then (ans' [f,0]) + (ans' [0,t])
  else (ans' [f,t])

main = do
  _ <- getLine
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Int]]
      o = map ans i
  mapM_ print o