import sys
from collections import deque


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    S = list(map(int, list(input())))
    d_1 = deque(S[1:])
    d_2 = deque([S[0]])
    ans = 0
    for i in range(1, len(S)):
        if d_2:
            r = d_1.popleft()
            l = d_2.pop()
            if r != l:
                ans += 2
            else:
                d_2.append(l)
                d_2.append(r)
        else:
            d_2.append(d_1.popleft())
    print(ans)


if __name__ == '__main__':
    main() import sys sys from collections import deque stdin = sys.stdin stdin sys.stdin sys stdin def ns(): return stdin.readline().rstrip() ns def ni(): return int(stdin.readline().rstrip()) ni def nm(): return map(int, stdin.readline().split()) nm def nl(): return list(map(int, stdin.readline().split())) nl def main():
    S = list(map(int, list(input())))
    d_1 = deque(S[1:])
    d_2 = deque([S[0]])
    ans = 0
    for i in range(1, len(S)):
        if d_2:
            r = d_1.popleft()
            l = d_2.pop()
            if r != l:
                ans += 2
            else:
                d_2.append(l)
                d_2.append(r)
        else:
            d_2.append(d_1.popleft())
    print(ans) main S = list(map(int, list(input()))) S list(map(int, list(input()))) list map(int, list(input())) map int list(input()) list input() input d_1 = deque(S[1:]) d_1 deque(S[1:]) deque S[1:] S 1: 1 d_2 = deque([S[0]]) d_2 deque([S[0]]) deque [S[0]] S[0] S 0 ans = 0 ans 0 for i in range(1, len(S)):
        if d_2:
            r = d_1.popleft()
            l = d_2.pop()
            if r != l:
                ans += 2
            else:
                d_2.append(l)
                d_2.append(r)
        else:
            d_2.append(d_1.popleft())
     i range(1, len(S)) range 1 len(S) len S if d_2:
            r = d_1.popleft()
            l = d_2.pop()
            if r != l:
                ans += 2
            else:
                d_2.append(l)
                d_2.append(r)
        else:
            d_2.append(d_1.popleft())
     d_2 r = d_1.popleft() r d_1.popleft() d_1.popleft d_1 popleft l = d_2.pop() l d_2.pop() d_2.pop d_2 pop if r != l:
                ans += 2
            else:
                d_2.append(l)
                d_2.append(r)
         r != l r l ans += 2 ans 2 d_2.append(l) d_2.append d_2 append l d_2.append(r) d_2.append d_2 append r d_2.append(d_1.popleft()) d_2.append d_2 append d_1.popleft() d_1.popleft d_1 popleft print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def ni(): return int(stdin.readline().rstrip()) def ni(): return int(stdin.readline().rstrip()) ni def ns(): return stdin.readline().rstrip() def ns(): return stdin.readline().rstrip() ns def nm(): return map(int, stdin.readline().split()) def nm(): return map(int, stdin.readline().split()) nm def main():
    S = list(map(int, list(input())))
    d_1 = deque(S[1:])
    d_2 = deque([S[0]])
    ans = 0
    for i in range(1, len(S)):
        if d_2:
            r = d_1.popleft()
            l = d_2.pop()
            if r != l:
                ans += 2
            else:
                d_2.append(l)
                d_2.append(r)
        else:
            d_2.append(d_1.popleft())
    print(ans) def main():
    S = list(map(int, list(input())))
    d_1 = deque(S[1:])
    d_2 = deque([S[0]])
    ans = 0
    for i in range(1, len(S)):
        if d_2:
            r = d_1.popleft()
            l = d_2.pop()
            if r != l:
                ans += 2
            else:
                d_2.append(l)
                d_2.append(r)
        else:
            d_2.append(d_1.popleft())
    print(ans) main def nl(): return list(map(int, stdin.readline().split())) def nl(): return list(map(int, stdin.readline().split())) nl stdin = sys.stdin sys.stdin stdin
import sys
from collections import deque


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    S = list(map(int, list(input())))
    d_1 = deque(S[1:])
    d_2 = deque([S[0]])
    ans = 0
    for i in range(1, len(S)):
        if d_2:
            r = d_1.popleft()
            l = d_2.pop()
            if r != l:
                ans += 2
            else:
                d_2.append(l)
                d_2.append(r)
        else:
            d_2.append(d_1.popleft())
    print(ans)


if __name__ == '__main__':
    main()
