mod=998244353 S=input() len_S=len(S) pow_2=[1] for _ in range(len_S+1): pow_2.append(pow_2[-1]*2%mod) D={"0":0,"1":1,"?":2} cntr=[0,0,0] cntl=[0,0,0] for s in S: cntr[D[s]]+=1 ans=0 for s in S: cntr[D[s]]-=1 if s!="0": x=cntl[2] y=cntr[2] ans+=(cntl[0]*pow_2[x]+x*pow_2[max(0,x-1)])*(cntr[0]*pow_2[y]+y*pow_2[max(0,y-1)]) ans%=mod cntl[D[s]]+=1 print(ans)