s = 0

p = 0

for c in eval(input()):

  n = int(c) * 2 - 1

  p += max(abs(s) - abs(s+n), 0) * 2

  s += n

print(p)
s = 0

S = eval(input())

for c in S:

  n = int(c) * 2 - 1

  s += n

print((len(S) - abs(s)))

s = 0
p = 0
for c in eval(input()):
    n = int(c) * 2 - 1
    p += max(abs(s) - abs(s + n), 0) * 2
    s += n
print(p)

s = 0
S = eval(input())
for c in S:
    n = int(c) * 2 - 1
    s += n
print((len(S) - abs(s)))

-p = 0 -for c in eval(input()): +S = eval(input()) +for c in S: -    p += max(abs(s) - abs(s + n), 0) * 2 -print(p) +print((len(S) - abs(s)))