s = gets.chomp
old = s[0]

count = 0
flag = false
flag2 = false

temp_count = 1

(1...s.size).each { |i|
	if old == s[i] then
		temp_count += 1
	else
            count += temp_count / 3 * 2
           	mod = temp_count % 3
            if mod > 0 then
                count += 1
            end

            if mod == 0 && flag then
                flag = false
                flag2 = true
            elsif mod > 1 then
                if flag then
                    count += 1
                    flag = false
                elsif flag2 then
                    count += 1
                    flag2 = false
                else
                    flag = true
                end
            else
                flag = false
                flag2 = false
            end
            temp_count = 1
        end
        old = s[i]
}

    count += temp_count / 3 * 2
    mod = temp_count % 3
    if mod > 0 then
        count +=1
    end
    if mod > 1 then
        if flag || flag2 then
            count += 1
        end
    end

    puts count
