import Data.List (sort)
import Control.Monad.State
import qualified Data.Map as M

main:: IO ()
main = do
    xs <- (map read . words) <$> getLine
    print $ solve xs

-- |
--
-- >>> solve [4,12,20]
-- 3
--
-- >>> solve [14,14,14]
-- -1
solve :: [Int] -> Int
solve as = rec 0 (sort as)
  where

    rec :: Int -> [Int] -> Int
    rec n xs@(xh:xts)
      | any odd xs = n
      | all (== xh) xts = -1
      | otherwise = rec (n+1) (sort $ next xs)

    next :: [Int] -> [Int]
    next xs = map (sum halves - ) halves
      where halves = map (`div` 2) xs
