{-# OPTIONS_GHC -O2 -optc-O2 #-}
{-# LANGUAGE BangPatterns #-}
module Main where

import Control.Applicative
import Control.Monad

hasNext :: (Int, Int, Int) -> Bool
hasNext (a, b, c) = even a && even b && even c

getNext :: (Int, Int, Int) -> (Int, Int, Int)
getNext (a, b, c) = (a', b', c')
    where ! a' = (b + c) `div` 2
          ! b' = (a + c) `div` 2
          ! c' = (a + b) `div` 2

states :: (Int, Int, Int) -> [(Int, Int, Int)]
states a | hasNext a = a : states (getNext a)
         | otherwise = [a]

getLength :: (Eq a) => [a] -> Int
getLength [] = 0
getLength [_] = 1
getLength xs = go (0, xs) (2, drop 2 xs)
    where go (tl, t) (hl, h) = case h of
                                 []  -> hl
                                 [_] -> hl + 1
                                 _   -> if head t == head h
                                        then (-1)
                                        else go (tl + 1, tail t) (hl + 2, drop 2 h)

main :: IO ()
main = do
  [a, b, c] <- map read . words <$> getLine
  let length = getLength $ states (a, b, c)
  if length < 0
  then print length
  else print (length - 1)
