io = STDIN
S=io.gets.chomp
@memo=Array.new(2*10**5,-1)
def bfs
  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] &&
      @memo[pos+1]<sum+1
      que << [S[pos,1],pos+1,sum+1]
      @memo[pos+1]=sum+1
    end
    if pos+2<= S.size &&
       before != S[pos,2] &&
       @memo[pos+2]<sum+1
       que << [S[pos,2],pos+2,sum+1]
       @memo[pos+2]=sum+1
    end
    if S.size==pos
      ans=sum if ans<sum
    end
  end
  ans
end
p bfs
