strs = gets.chomp.chars
sl = strs.size
k = 0
sl.times do |i|
  if i == 0
    if strs[i]!=strs[i+1]
      strs[i] = nil
      k += 1
    end
  elsif i == sl-1
    if strs[i-1]!=strs[i]
      strs[i] = nil
      k += 1
    end
  elsif strs[i-1]!=strs[i] and strs[i]!=strs[i+1]
    strs[i] = nil
    k += 1
  end
end
continuous = 1
strs.inject do |i,j|
  if !i.nil? and !j.nil?
    continuous += 1
  else
    k += continuous/3*2
    if continuous!=1 and continuous%3>0
      k += 1
    end
    continuous = 1
  end
  j
end
k += continuous/3*2
if continuous!=1 and continuous%3>0
  k += 1
end
print("#{k}")