def func(s)
  if s == '' then
    return s
  end
  
  i = 0  
  while i < (s.size - 1) do
    if s[i] != s[i + 1] then
      s[i + 1] = s[i] = 'x'
      i += 2
    else
      i += 1
    end
  end
  
  return s.delete('x')
end

def main(argv)
  s = gets.chomp
  c = 0
  
  while true do
    t = func(s.dup)

    if s == t then
      break
    end
    
    c += (s.size - t.size)
    s = t
  end

  puts c.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end