import Data.List
import Data.Bool

main = putStrLn . unwords . map show . solve =<< getLine

solve :: String -> [Int]
solve s = let i = solve' 1 s in bool [i,i+1] [-1,-1] $ i == -1

solve' _ [c1,c2] = bool (-1) 1 $ c1 == c2
solve' i (c1:s'@(c2:c3:cs)) = bool (solve' (succ i) s') i . (/=3) . length . group $ sort [c1,c2,c3]
