import Data.Bifunctor (bimap, first, second)
import Data.Foldable  (and, or, product, sum)
import Data.Function
import Data.Monoid    ((<>))

import qualified Data.List as L

import Control.Applicative
import Control.Monad

main :: IO ()
main = do
    s <- getLine
    answer $ solve s

type Answer = (Int, Int)
answer :: Answer -> IO ()
answer (a, b) = putStrLn $ show a ++ " " ++ show b

solve :: String -> Answer
solve s =
  let
    subs =
        L.zip [1..] (L.tails s)
        & L.map (second (L.zip [0..] . L.inits))
        & L.concatMap (\(a, xs) -> L.map (\(b, s) -> ((a, b), s)) xs)
  in case L.map fst $ L.filter (unbalanced . snd) subs of
    []      -> (-1, -1)
    range:_ -> range

unbalanced :: String -> Bool
unbalanced s =
  let
    nummode = L.maximum . L.map L.length . L.group $ L.sort s
    l       = L.length s
  in
    l >= 2 && l - nummode < nummode
