import Data.List
import Data.Bool

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

solve :: String -> [Int]
solve = solve' 1

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