program prob3
    implicit none
    character(len=200005) :: s    
    integer :: a(200005)
    integer :: i, cnt, tmpi, ans, tmp
    character :: tmps
    logical :: check

    read(*,*) s

    do i = 1, 200005
        a(i) = 0
    end do

    cnt = 1
    tmpi = 1
    tmps = s(1:1)
    do i = 1, len_trim(s)-1
        if(s(i:i) /= s(i+1:i+1)) then
            a(tmpi) = cnt
            cnt = 1
            tmpi = tmpi + 1
            tmps = s(i+1:i+1)
        else
            cnt = cnt + 1
        end if
    end do
    a(tmpi) = cnt

    ans = 0
    check = .false.
    do i = 1, 200005
        tmp = a(i) / 3
        tmp = tmp * 2
        if(mod(a(i), 3) >= 1) then
            tmp = tmp + 1
        end if
        if(mod(a(i), 3) == 2 .and. mod(a(i+1), 3) == 2) then
            if(check .eqv. .false.) then
                tmp = tmp + 1
                check = .true.
            else
                check = .false.
            end if
        else
            check = .false.
        end if
        ans = ans + tmp
    end do
    
    write(*,*) ans
    stop
contains
end program prob3