a = gets.chomp.split('')
n = a.length - 1
ans = []
a.each_with_index do |s, idx|
  break if a[idx] == a[idx+1]
  if idx == a.length - 1 then
    puts a.length
    exit
  end
end
0.upto((2**n)-1) do |i|
  buf = ""
  bin = "%0#{n}d" % i.to_s(2)
  bin.split('').each_with_index do |s, idx|
    if s == "1"
      buf += "#{a[idx]}+"
    else
      buf += "#{a[idx]},"
    end
  end
  buf += a[-1]
  buf_split = buf.split(',')
  buf_split.each_with_index do |s, idx|
    break if buf_split[idx] == buf_split[idx+1]
    ans << buf_split.length if idx == buf_split.length - 1
  end
end
puts ans.max