import Data.List
f n x=if null x then 0 else if even x then f n+1 x`div`2 else n
main=do
 s<-sort<$>map read.words<$>getLine
 let p=map(f 0)[s!!1-head s,last s-head s,last s-s!!1]
 print$if all(==(0))p && even(head s) then -1 else minimum p