array=gets.chomp.split("")
array2=[]

def tanaka(aa)
    
    pp=2
    bb=aa.uniq
    i=0
    bb.length.times{
        kk=aa.count(bb[i])
        if kk%2==1
            pp-=1
        end
        
        i+=1
        
        if pp<=0
            break
        end
        
        
        
    }
    
   if pp==2
       return "g"
       elsif pp==1
       return "k"
   else return "n"
    
end
        
    
    
end


ii=0
jj=1
max=0

loop{
    if tanaka(array[ii..jj])=="g"
    array2<<"g"
    max=jj
    ii=jj+1
    jj=jj+2
    
    
    elsif tanaka(array[ii..jj])=="k"
    array2<<"k"
    max=jj
    ii=jj+1
    jj=jj+2
    
    
    
else jj+=1
end


if jj>=array.length && ii<=array.length-3
 array2<<"k"
  ii=ii+1
   jj=ii+1
end


if jj>=array.length && ii>=array.length-2  && tanaka(array[ii..jj])=="n"
array2<<"k"
array2<<"k"
break
end



if ii>=array.length
break
end
    

}


p array2.count("k")




