from collections import Counter
s = input().rstrip()
ctr = Counter(s)
if len(ctr) == 2:
    x = min(ctr.values())
else:
    x = 0
print(x * 2) from collections import Counter s = input().rstrip() s input().rstrip() ().rstrip () input rstrip ctr = Counter(s) ctr Counter(s) Counter s if len(ctr) == 2:
    x = min(ctr.values())
else:
    x = 0 len(ctr) == 2 len(ctr) len ctr 2 x = min(ctr.values()) x min(ctr.values()) min ctr.values() ctr.values ctr values x = 0 x 0 print(x * 2) print x * 2 x 2 s = input().rstrip() input().rstrip() s x = 0 0 x x = min(ctr.values()) min(ctr.values()) x ctr = Counter(s) Counter(s) ctr
from collections import Counter
s = input().rstrip()
ctr = Counter(s)
if len(ctr) == 2:
    x = min(ctr.values())
else:
    x = 0
print(x * 2)