object Main {
  def main(args: Array[String]) = {

    val sc = new java.util.Scanner(System.in)
    val s = sc.next
    sc.close()

    if (s.length == 1) {
      println(s.length)
    } else {
      val ks = calc(s.drop(1), List(s.head.toString))
      ks.takeRight(2).distinct.length match {
        case 1 => println(ks.length - 1)
        case _ => println(ks.length)
      }
    }

    def calc(xs: String, k: List[String]): List[String] = xs.isEmpty match {
      case true => k
      case _ => {
        if (k.last == xs.head.toString) {
          calc(xs.drop(2), k :+ xs.take(2))
        } else
          calc(xs.drop(1), k :+ xs.take(1))
      }
    }
  }
}