s=list(map(int,list(input())))
from collections import Counter
s+=[0,1]
cs=Counter(s)
print(min(cs.values())*2-2) s=list(map(int,list(input()))) s list(map(int,list(input()))) list map(int,list(input())) map int list(input()) list input() input from collections import Counter s+=[0,1] s [0,1] 0 1 cs=Counter(s) cs Counter(s) Counter s print(min(cs.values())*2-2) print min(cs.values())*2-2 min(cs.values())*2 min(cs.values()) min cs.values() cs.values cs values 2 2 s+=[0,1] [0,1] s s=list(map(int,list(input()))) list(map(int,list(input()))) s cs=Counter(s) Counter(s) cs
s=list(map(int,list(input())))
from collections import Counter
s+=[0,1]
cs=Counter(s)
print(min(cs.values())*2-2)