str = input()
c = list(str)
s = []

c_now = ""
s_now = ""

cnt = 0
c_len = len(c)

for i in range(len(c)):
    if s_now != c_now:
        s.append(c_now)
        s_now = c_now
        cnt = cnt + 1
        if i != len(c)-1:
            c_now = c[i+1]
    else:
        c_now += c[i]


if c[c_len-3] == c[c_len-2] and c[c_len-2] == c[c_len-1] :
    cnt = cnt - 1





str = str[::-1]
c = list(str)
s = []

c_now = ""
s_now = ""

cnt2 = 0
c_len = len(c)

for i in range(len(c)):
    if s_now != c_now:
        s.append(c_now)
        s_now = c_now
        cnt2 = cnt2 + 1
        if i != len(c)-1:
            c_now = c[i+1]
    else:
        c_now += c[i]


if c[c_len-3] == c[c_len-2] and c[c_len-2] == c[c_len-1] :
    cnt2 = cnt2 + 1




if cnt > cnt2:
    print(cnt)
else:
    print(cnt2)



'''2nd
for i in range(c_len-1):
    if c_now != c[i+1]:
        s.append(c_now)
        cnt = cnt + 1
        c_now = c[i]
    else:
        c_now = c_now + c[i]


if c[c_len-6] != c[c_len-5] and c[c_len-5] == c[c_len-4] and c[c_len-4] == c[c_len-3] and c[c_len-3] == c[c_len-2] and c[c_len-2] == c[c_len-1] :
    cnt = cnt - 1

print(cnt)
'''



'''
str = input()
c = list(str)
s = []

c_now = ""
s_now = ""

cnt = 0

for i in range(len(c)):
    if s_now != c_now:
        s.append(c_now)
        s_now = c_now
        cnt = cnt + 1
        if i != len(c)-1:
            c_now = c[i+1]
    else:
        c_now += c[i]

print(cnt)
'''
