program main
  implicit none
  character(100000) :: s
  character(1), allocatable :: colors(:)
  integer :: i, j, n, even = 0, odd = 0, cnt = 0
  integer, allocatable :: pos(:)

  read *, s
  n = len_trim(s)
  allocate (colors(n), pos(n/2))

  do i = 1, n
    colors(i) = s(i:i)
  end do

  do i = 1, n
    if (s(i:i+2) == '000') then
      s(i:i+2) = '010'
      cnt = cnt + 1
    elseif (s(i:i+2) == '111') then
      s(i:i+2) = '101'
      cnt = cnt + 1
    end if
  end do

  j = 1
  do i = 1, n
    if ((s(i:i+1) == '00') .or. (s(i:i+1) == '11')) then
      pos(j) = i
      if ((j > 1) .and. mod(j, 2) == 0)  even = even + pos(j) - pos(j-1)
      if ((j > 1) .and. mod(j, 2) == 1)  odd = odd + pos(j) - pos(j-1)
      j = j + 1
    end if
  end do
  if (odd==0) odd = 2*n

  print '(i0)', cnt + min(even, odd)
    
end

