s = read_line
if s.size == 1
  puts 1
  exit
end
if s.size == 2
  if s[0] == s[1]
    puts 1
  else
    puts 2
  end
  exit
end
cs = s.chars.map(&.to_s)
ret = 0_u64
prev_token = ""
current_token = ""
cs.each_with_index do |c, i|
  if i == cs.size - 3 
    tail = s[-3..-1].chars
    if tail[0] == tail[1] || tail[1] == tail[2]
      puts ret + 2
    else
      puts ret + 3
    end
    exit
  end
  current_token += c
  if prev_token != current_token
    prev_token, current_token = current_token, ""
    ret += 1
  end
end