program name
    implicit none
    character(100000):: s, f
    integer(4):: len_s,i, diff

    read*, s
    len_s = len_trim(s)

    f(1:1) = '0'
    do i=2,len_s
        f(i:i) = char(ichar('0')+ichar('1') - ichar(f(i-1:i-1)))
    end do

    diff = 0
    do i=1,len_s
        if (s(i:i) == f(i:i)) diff=diff+1
    end do

    print*, min(diff, len_s-diff)
end program name