import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val s = scanner.next()
    val sArray = s.toCharArray()
    var count = 0
    var eCount = 2
    var prevCount = 0
    var i = 0
    var j = 0
    while(i+1<sArray.size){
        if(sArray[i] === sArray[i+1]){
            j = i+1
            while (j+1 < sArray.size) {
                if (sArray[j] === sArray[j + 1]) {
                    eCount++
                } else break
                j++
            }
            if(eCount === 2){
                if(j === sArray.size-1) {
                    count += 1
                    i += 2
                }
                else {
                    count += 2
                    i += 3
                    //prevString = prevString+sArray[i+1]+sArray[i+2]
                }
            }
            else if(eCount%3 === 0){
                count += (eCount / 3) * 2
                i += eCount
                eCount = 2
            }
            else{
                count += (eCount / 3) * 2 + 1
                i += eCount
                eCount = 2
            }
            if(eCount !== 2 && prevCount % 3 === 2 && eCount % 3 === 2) count++
            if(i === sArray.size-1) count++
            prevCount = eCount
        }
        else{
          if(i+1 === sArray.size-1){
              count += 2
              i++
          }
          else{
              count++
              i++
          }
        }
    }
    println(count)
}