pre_input_line = input("")
input_line = []
for c in  pre_input_line:
    input_line.append(c)
input_line += ["END"]
string_letters = ""
string_list = []
for i in range(len(input_line)-1):
    if input_line[i] == input_line[i+1]:
        string_letters += input_line[i]
    else:
        string_letters += input_line[i]
        string_list.append(string_letters)
        string_letters = ""
K = 0
count = 0
for n in range(len(string_list)):
    if len(string_list[n]) % 3 == 2:
        count += 1
        if count == 2:
            K += (len(string_list[n-1]) + len(string_list[n]))//6 * 4 + 3
            count = 0
    else:
        if count == 1:
            K += len(string_list[n-1])//3 * 2 + 1
            count = 0
        if len(string_list[n]) % 3 == 0:
            K += len(string_list[n])//3 * 2
        else:
            K += len(string_list[n]) // 3 * 2 + 1
if count == 1:
    K += len(string_list[-1]) // 3 * 2 + 1
print(K)