io = STDIN
S=io.gets.chomp
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]
      que << [S[pos,1],pos+1,sum+1]
    end
    if pos+2<= S.size && before != S[pos,2]
      que << [S[pos,2],pos+2,sum+1]
    end
    ans=[ans,sum].max if S.size==pos
  end
  ans
end
p bfs
