import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

s = input()

o = 0
z = 0
ans = 0
for i in range(len(s) - 1):
    if s[i] == '0':
        o += 1
    else:
        z += 1
    if s[i] != s[i + 1]:
        mi = min(o, z)
        ans += mi * 2
        o -= mi
        z -= mi

print(ans) import sys sys sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline s = input() s input() input o = 0 o 0 z = 0 z 0 ans = 0 ans 0 for i in range(len(s) - 1):
    if s[i] == '0':
        o += 1
    else:
        z += 1
    if s[i] != s[i + 1]:
        mi = min(o, z)
        ans += mi * 2
        o -= mi
        z -= mi i range(len(s) - 1) range len(s) - 1 len(s) len s 1 if s[i] == '0':
        o += 1
    else:
        z += 1
     s[i] == '0' s[i] s i '0' o += 1 o 1 z += 1 z 1 if s[i] != s[i + 1]:
        mi = min(o, z)
        ans += mi * 2
        o -= mi
        z -= mi s[i] != s[i + 1] s[i] s i s[i + 1] s i + 1 i 1 mi = min(o, z) mi min(o, z) min o z ans += mi * 2 ans mi * 2 mi 2 o -= mi o mi z -= mi z mi print(ans) print ans z -= mi mi z s = input() input() s o = 0 0 o z = 0 0 z o += 1 1 o ans = 0 0 ans mi = min(o, z) min(o, z) mi o -= mi mi o input = sys.stdin.readline sys.stdin.readline input z += 1 1 z ans += mi * 2 mi * 2 ans
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

s = input()

o = 0
z = 0
ans = 0
for i in range(len(s) - 1):
    if s[i] == '0':
        o += 1
    else:
        z += 1
    if s[i] != s[i + 1]:
        mi = min(o, z)
        ans += mi * 2
        o -= mi
        z -= mi

print(ans)
