first = input() x = first[0] num = [0] ans = 0 n = 0 for i in range(len(first)): if first[i] == x: s=1 else: s=-1 n += 1*s num.append(n) print(num) n_min = min(num) n_max = max(num) for i in range(n_min, n_max): le=0 while num[le] != num[i]: le +=1 ri=len(num)-1 while num[ri] != num[i]: ri -=1 a = ri - le if ans