io = STDIN
S=io.gets.chomp
@memo1=Array.new(S.size+1,-1)
@memo2=Array.new(S.size+1,-1)
def sub(item)
  before,pos,sum=item
    if pos+1<= S.size &&
    before != S[pos,1] &&
    $que.unshift([S[pos,1],pos+1,sum+1])
  end
  if pos+2<= S.size &&
      before != S[pos,2] &&
      $que.unshift([S[pos,2],pos+2,sum+1])
  end
end
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 before.size==1 &&
       @memo1[pos]<sum
       sub(item)
       @memo1[pos]=sum
    elsif before.size==2 &&
      @memo2[pos]<sum
       sub(item)
        @memo2[pos]=sum
    end

    if S.size==pos
      ans=sum if ans<sum
    end
  end
  ans
end
p dfs
