Tiles=input()
N_len=len(Tiles)
if N_len == 1:
    print("0")
    return
    
cur=Tiles[0]

change=0
for i in range(1, N_len):
    #print("i={}".format(i))
    #print("cur={}".format(cur))
    #print("next={}".format(Tiles[i]))
    if cur is Tiles[i]:
        change+=1

        if Tiles[i] == "0":
            cur = "1"
        else:
            cur ="0"
    else:
        cur=Tiles[i]

    #print("new cur={}".format(cur))

min_change = change


change_first=1
if Tiles[0] == "0":
    cur = "1"
else:
    cur = "0"

for i in range(1, N_len):
    #print("i={}".format(i))
    #print("cur={}".format(cur))
    #print("next={}".format(Tiles[i]))
    if cur is Tiles[i]:
        change_first+=1
        if min_change <= change_first:
            break

        if Tiles[i] == "0":
            cur = "1"
        else:
            cur ="0"
    else:
        cur=Tiles[i]
        
if min_change > change_first:
    min_change = change_first

        
change_reverse=0
cur=Tiles[N_len-1]
for i in reversed(range(0, N_len-1)):
    #print("i={}".format(i))
    #print("cur={}".format(cur))
    #print("next={}".format(Tiles[i]))
    if cur is Tiles[i]:
        change_reverse+=1
        if min_change <= change_reverse:
            break


        if Tiles[i] == "0":
            cur = "1"
        else:
            cur ="0"
    else:
        cur=Tiles[i]

    #print("new cur={}".format(cur))
    
if min_change > change_reverse:
    min_change = change_reverse


change_reverse_first=1
if Tiles[N_len-1] == "0":
    cur = "1"
else:
    cur = "0"

for i in reversed(range(0, N_len-1)):
    #print("i={}".format(i))
    #print("cur={}".format(cur))
    #print("next={}".format(Tiles[i]))
    if cur is Tiles[i]:
        change_reverse_first+=1
        if min_change <= change_reverse_first:
            break

        if Tiles[i] == "0":
            cur = "1"
        else:
            cur ="0"
    else:
        cur=Tiles[i]

if min_change > change_reverse_first:
    min_change = change_reverse_first
    
print(min_change)

### FIXED CODE ###

Tiles=input()
N_len=len(Tiles)
if N_len == 1:
    print("0")
    exit()
    
cur=Tiles[0]

change=0
for i in range(1, N_len):
    #print("i={}".format(i))
    #print("cur={}".format(cur))
    #print("next={}".format(Tiles[i]))
    if cur is Tiles[i]:
        change+=1

        if Tiles[i] == "0":
            cur = "1"
        else:
            cur ="0"
    else:
        cur=Tiles[i]

    #print("new cur={}".format(cur))

min_change = change


change_first=1
if Tiles[0] == "0":
    cur = "1"
else:
    cur = "0"

for i in range(1, N_len):
    #print("i={}".format(i))
    #print("cur={}".format(cur))
    #print("next={}".format(Tiles[i]))
    if cur is Tiles[i]:
        change_first+=1
        if min_change <= change_first:
            break

        if Tiles[i] == "0":
            cur = "1"
        else:
            cur ="0"
    else:
        cur=Tiles[i]
        
if min_change > change_first:
    min_change = change_first

        
change_reverse=0
cur=Tiles[N_len-1]
for i in reversed(range(0, N_len-1)):
    #print("i={}".format(i))
    #print("cur={}".format(cur))
    #print("next={}".format(Tiles[i]))
    if cur is Tiles[i]:
        change_reverse+=1
        if min_change <= change_reverse:
            break


        if Tiles[i] == "0":
            cur = "1"
        else:
            cur ="0"
    else:
        cur=Tiles[i]

    #print("new cur={}".format(cur))
    
if min_change > change_reverse:
    min_change = change_reverse


change_reverse_first=1
if Tiles[N_len-1] == "0":
    cur = "1"
else:
    cur = "0"

for i in reversed(range(0, N_len-1)):
    #print("i={}".format(i))
    #print("cur={}".format(cur))
    #print("next={}".format(Tiles[i]))
    if cur is Tiles[i]:
        change_reverse_first+=1
        if min_change <= change_reverse_first:
            break

        if Tiles[i] == "0":
            cur = "1"
        else:
            cur ="0"
    else:
        cur=Tiles[i]

if min_change > change_reverse_first:
    min_change = change_reverse_first

print(str(min_change))