S = gets.to_s.split("")

eq = 1
arr = []
S.reduce("") { |a, s|
  if s == a
    eq += 1
  else
    arr << eq
    eq = 1
  end
  s
}
arr << eq
ans = 0
ans = arr.reduce(0) { |n, m| n = n + (m / 2)} 

check = false
arr.reduce([]) { |a ,b|
  a << b
  if a.size > 3
    a.shift
  end
  if a.size == 3 && a[0] == 1 && a[1] % 2 == 0 && a[2] == 1
    ans += 1
    a = []
  end
  a
}

p ans
