io = STDIN
S=io.gets.chomp
@memo1=Array.new(S.size+1,-1)
@memo2=Array.new(S.size+1,-1)
def dfs
  ans=-1
  if S.size==1
    que=[[S[0,1],1,1]]
  else
    que=[[S[0,1],1,1],[S[0,2],2,1]]
  end
  while item = que.shift
    before,pos,sum=item
    if pos+1<= S.size &&
      before != S[pos,1] &&
      @memo1[pos+1]<sum+1
      que.unshift([S[pos,1],pos+1,sum+1])
      @memo1[pos+1]=sum+1
    end
    if pos+2<= S.size &&
       before != S[pos,2] &&
       @memo2[pos+2]<sum+1
       que.unshift([S[pos,2],pos+2,sum+1])
       @memo2[pos+2]=sum+1
    end
    if S.size==pos
      ans=sum if ans<sum
    end
  end
  ans
end
p dfs
