S = gets.chomp

f = 1
str = S
tmp = str
while f == 1 do
    str = str.split('01')
    str = str.join
    str = str.split('10')
    str = str.join
    if str.eql?(tmp) then
        f = 0
    end
    tmp = str
end

print S.length - str.length
