import Data.Either (either, isLeft, isRight, lefts, partitionEithers, rights)
import Data.Maybe
    ( catMaybes
    , fromJust
    , fromMaybe
    , isJust
    , isNothing
    , listToMaybe
    , mapMaybe
    , maybe
    , maybeToList
    )

import           Data.Array.IArray (IArray, (!))
import qualified Data.Array.IArray as I (array, assocs, elems, listArray)
import           Data.Array.MArray (MArray)
import qualified Data.Array.MArray as M
    ( freeze
    , getAssocs
    , getElems
    , newArray
    , newListArray
    , readArray
    , writeArray
    )

import Data.Array.IO      (IOArray, IOUArray)
import Data.Array.ST      (STArray, STUArray)
import Data.Array.Unboxed (UArray)

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
import Control.Monad.ST    (ST, runST)

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
  in case L.map fst $ L.filter (unbalanced . snd) subs of
    []  -> (-1, -1)
    a:_ -> (a, L.length s - 1)

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
