# 1
# https://atcoder.jp/contests/diverta2019/tasks/diverta2019_a
if False:
    N,K=map(int,input().split())
    print(N-K+1)

# 2
# https://atcoder.jp/contests/m-solutions2019/tasks/m_solutions2019_b
if False:
    print('NO' if input().count('x')>7 else 'YES')

# 3
# https://atcoder.jp/contests/m-solutions2019/tasks/m_solutions2019_a
if False:
    print((int(input())-2)*180)

# 4
# https://atcoder.jp/contests/agc037/tasks/agc037_a
if True:
    S=list(input())
    ans=0
    cnt=1
    prev=S[0]
    tmp=''
    for s in S[1:]:
        tmp+=s
        # print(tmp)
        if tmp==prev:
            continue
        else:
            cnt+=1
            prev=tmp
            tmp=''
    if tmp and tmp!=prev:
        cnt+=1
        ans=max(cnt,ans)
    elif not tmp:
        ans=max(cnt,ans)
    # print(cnt)
    cnt=1
    prev=S[:2]
    tmp=''
    for s in S[2:]:
        tmp+=s
        # print(tmp)
        if tmp==prev:
            continue
        else:
            cnt+=1
            prev=tmp
            tmp=''
    if tmp and tmp!=prev:
        cnt+=1
        ans=max(cnt,ans)
    elif not tmp:
        ans=max(cnt,ans)
    print(ans)
    


# 5
# https://atcoder.jp/contests/agc041/tasks/agc041_a
if False:
    N,A,B=map(int,input().split())
    d=B-A
    if d%2==0:
        ans=d//2
    else:
        ans=min(A-1,N-B)+1+(d-1)//2
    print(ans)
