#!/usr/bin/env python3
import sys

def solve(S: str):
    stack = [-1]
    for c in map(int, S):
        if stack[-1] + c == 1:
            stack.pop()
            continue
        stack.append(c)
    return len(S)-len(stack)+1

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    print(solve(S))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main() import sys sys def solve(S: str):
    stack = [-1]
    for c in map(int, S):
        if stack[-1] + c == 1:
            stack.pop()
            continue
        stack.append(c)
    return len(S)-len(stack)+1

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools solve stack = [-1] stack [-1] -1 for c in map(int, S):
        if stack[-1] + c == 1:
            stack.pop()
            continue
        stack.append(c)
     c map(int, S) map int S if stack[-1] + c == 1:
            stack.pop()
            continue
         stack[-1] + c == 1 stack[-1] + c stack[-1] stack -1 c 1 stack.pop() stack.pop stack pop continue stack.append(c) stack.append stack append c return len(S)-len(stack)+1 len(S)-len(stack)+1 len(S)-len(stack) len(S) len S len(stack) len stack 1 S: str S def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    print(solve(S)) main def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
     iterate_tokens for line in sys.stdin:
            for word in line.split():
                yield word
     line sys.stdin sys stdin for word in line.split():
                yield word
     word line.split() line.split line split yield word word tokens = iterate_tokens() tokens iterate_tokens() iterate_tokens S = next(tokens) S next(tokens) next tokens print(solve(S)) print solve(S) solve S def test():
    import doctest
    doctest.testmod() test import doctest doctest doctest.testmod() doctest.testmod doctest testmod if __name__ == '__main__':
    #test()
    main() __name__ == '__main__' __name__ '__main__' main() main def test():
    import doctest
    doctest.testmod() def test():
    import doctest
    doctest.testmod() test def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    print(solve(S)) def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    print(solve(S)) main def solve(S: str):
    stack = [-1]
    for c in map(int, S):
        if stack[-1] + c == 1:
            stack.pop()
            continue
        stack.append(c)
    return len(S)-len(stack)+1

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools def solve(S: str):
    stack = [-1]
    for c in map(int, S):
        if stack[-1] + c == 1:
            stack.pop()
            continue
        stack.append(c)
    return len(S)-len(stack)+1

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools solve
#!/usr/bin/env python3
import sys

def solve(S: str):
    stack = [-1]
    for c in map(int, S):
        if stack[-1] + c == 1:
            stack.pop()
            continue
        stack.append(c)
    return len(S)-len(stack)+1

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    print(solve(S))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()
