local function str2tbl(s)
    -- limit of #s is approximately 999959
    local t = {string.byte(s, 1, #s)}
    local char = string.char
    for i=1, #t do
        t[i] = char(t[i])
    end
    return t
end
local S = str2tbl(io.read("l"))
local function solve()
    if #S == 1 then
        return 1
    elseif #S == 2 then
        return S[1] == S[2] and 1 or 2
    end
    local dp = {}
    for i=1,#S do dp[i] = {0, 0} end
    local function print_dp()
        for i=1,#S do print(i, dp[i][1], dp[i][2]) end
    end
    dp[1][1] = 1
    dp[1][2] = 0
    dp[2][1] = S[1] == S[2] and 0 or 2
    dp[2][2] = 1
    dp[3][1] = (dp[2][2] + 1) + (S[2] == S[3] and 0 or dp[2][1])
    dp[3][2] = 2
    for i=4,#S do
        -- for dp[i][1]
        local case2 = dp[i-1][2] ~= 0 and dp[i-1][2] + 1 or 0
        local case1
        if S[i] ~= S[i-1] then
            case1 = dp[i-1][1] + 1
        else
            case1 = 0
        end
        dp[i][1] = math.max(case1, case2)
        -- for dp[i][2]
        case1 = dp[i-2][1] ~= 0 and dp[i-2][1] + 1 or 0
        local now = S[i-1]..S[i]
        local prev = S[i-3]..S[i-2]
        if now ~= prev then
            case2 = dp[i-2][2] + 1
        else
            case2 = 0
        end
        dp[i][2] = math.max(case1, case2)
    end
    --print_dp()
    return math.max(dp[#S][1], dp[#S][2])
end
print(solve())