S = input()
a = ""
stock = ""
data = []

for i in S:
    a = a + i
    if a != stock:
        stock = a
        data.append(a)
        a = ""
count = len(data)


if a == stock:
    i = 1
    data.append(a)
    while True:
        word = ""
        a = ""
        stock2 = ""
        data2 = []
        for j in range(i+1):
            word = word + data[j-2]
        
        for j in reversed(word):
            a = j + a
            if a != stock2:
                stock2 = a
                data2.insert(0,a)
                a = ""
        if (data2[0] != data[-(i+2)]) and (a == ""):
            count = len(data) - (i+1) + len(data2)
            break
        i += 1
        

print(count)