def main(): S=input() N=len(S) Zero=S.count('0') One=N-Zero cnt=[0]*4 for i in range(N): if S[i]=='0': cnt[0]+=(i+1) cnt[1]+=N-i else: cnt[2]+=(i+1) cnt[3]+=N-i L=0 Z=0 if Zero<=One: Z=Zero L=min(cnt[0],cnt[1]) else: Z=One L=min(cnt[2],cnt[3]) dp=[[0 for i in range(L+1)] for j in range(Z+1)] dp[0][0]=1 for i in range(1,N+1): ndp=[[0 for i in range(L+1)] for j in range(Z+1)] for j in range(Z+1): for k in range(L+1): ndp[j][k]+=dp[j][k] if j>0 and k-i>=0: ndp[j][k]+=dp[j-1][k-i] ndp[j][k] dp=ndp print(dp[Z][L]) if __name__=='__main__': main()