# frozen_string_literal: true

s = gets

array = s.split('')
array_answer = []
flag_skip = false
flag_2char = false
max = 0

array.each_index do |i|
  begin
    if flag_skip
      flag_skip = false
      next
    end

    if array_answer.last == array[i] + array[i + 1]
      array_answer << array[i]
      next
    end

    if array_answer.last == array[i]
      array_answer << array[i] + array[i + 1]
      flag_skip = true
      next
    end

    if array[i] == array[i + 1]
      array_answer << array[i] + array[i + 1]
      flag_skip = true
      next
    else
      array_answer << array[i]
    end
  rescue StandardError
    next
  end
end
# puts array_answer
max = array_answer.length if max < array_answer.length

array_answer = []
array.each_index do |i|
  begin
    if flag_skip
      flag_skip = false
      next
    end

    if flag_2char
      array_answer << array[i] + array[i + 1]
      flag_2char = false
      flag_skip = true
      next
    end

    if array_answer.last == array[i] + array[i + 1]
      array_answer << array[i]
      next
    end

    if array_answer.last == array[i]
      array_answer << array[i] + array[i + 1]
      flag_skip = true
      next
    end

    if array[i] == array[i + 1]
      break if i == array.length - 1

      array_answer << array[i]
      flag_2char = true
      next
    end

    array_answer << array[i]
  rescue StandardError
    break
  end
end
# puts array_answer
max = array_answer.length if max < array_answer.length

puts max
