S = gets.chomp
N = S.size
output = [""]
n = 0
S.each_char do |c|
  s = output[n]
  pp [output[n], n, c].join(",")
  if s == ""
    output[n] += c
  elsif s[0] == c
    output[n].delete!(c)
  else
    n += 1
    output[n] = c
  end
end
# pp output
while true
  output2 = [output[0]]
  output[1..-1].each do |s|
    if output2[-1] == s
      output2[-1] = ""
    elsif output2[-1] == ""
      output2[-1] = s
    elsif s == ""
    else
      output2 << s
    end
  end
  # pp output2
  if output.size == output2.size
    break
  end
  output = output2
end
puts output.size
