def change(S,a,b,c,d): return S[:a]+S[c:d+1]+S[b+1:c]+S[a:b+1]+S[d+1:] S=input() N=len(S) E={S} for tl in range(N): t0=t1=0 for tr in range(tl,N): if S[tr]=="0": t0+=1 else: t1+=1 for ul in range(tr+1,N): u0=u1=0 for ur in range(ul,N): if S[ur]=="0": u0+=1 else: u1+=1 if t0==u0 and t1==u1: E.add(change(S,tl,tr,ul,ur)) print(len(E))