

object Main extends App {
  def searchPartialUnbalanced(l: List[Char]): (Int, Int) = {
    def go(list: List[(Char, Int)]): (Int, Int) = {
      list match {
        case Nil                                 ⇒ (-1, -1)
        case (a, ai) :: (b, bi) :: t if (a == b) ⇒ (ai + 1, bi + 1)
        case (a, ai) :: _ :: (b, bi) :: t if (a == b) ⇒
          (ai + 1, bi + 1)
        case _ :: t ⇒ go(t)

      }
    }
    go(l.zipWithIndex)
  }
  val (from, to) = searchPartialUnbalanced(scala.io.StdIn.readLine.toList)
  println(from + " " + to)
}