S = input()
N = len(S)

Data = list(S)
Data = list(map(int,Data))

delnum = 1

while delnum != 0:
    i = 0
    delnum = 0
    while i < N:
        while i < N and Data[i] == -1:
            i += 1
        if i >= N:
            break

        c = Data[i]
        #
        c1_pos = i
        j = i + 1
        c1_count = 1 
        while j < N and (Data[j] == c or Data[j]==-1):
            if Data[j] == c:
                c1_count += 1
            j += 1
        #
        c2_pos = j
        c2_count = 0
        k = j
        while k < N and (Data[j] == (1-c) or Data[j] == -1):
            if Data[k] == 1-c:
                c2_count += 1
            k += 1

        i = k

        delnum = min(c1_count,c2_count)
        d = 0
        ii = 0

        while d < delnum:
            if Data[c1_pos+ii] == c:
                Data[c1_pos+ii]= -1
                d += 1
            ii += 1
        d = 0
        ii = 0
        while d < delnum:
            if Data[c2_pos+ii] == 1-c:
                Data[c2_pos+ii] = -1
                d += 1
            ii += 1
        
ans = 0
for n in Data:
    if n == -1:
        ans += 1
print(ans)
