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
    l       = L.length s
    substrs = s
        & L.init . L.tails
        & L.concatMap (L.tail . L.inits)
        & L.zip [(a, b) | a <- [1 .. l], b <- [a .. l]]
  in case L.map fst $ L.filter (unbalanced . snd) substrs 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
