S=list(str(input()))
N=len(S)
s=0
ans=0
tmp=[]
def dp(s,ans,tmp):
  if s==N-1:
    return ans
  if (S[s]!=S[s+1]):
    ans+=2
    if tmp!=[] and s+1==N-2:
      if S[-1]!=tmp[-1]:
        return ans+2
    if s+1==N-1:
      return ans
    return dp(s+2,ans,tmp)
  elif tmp!=[] and tmp[-1]!=S[s]:
    ans+=2
    return dp(s+1,ans,tmp)
  else:
    tmp.append(S[s])
    return dp(s+1,ans,tmp)

print(dp(s,ans,tmp))