S=input().strip() ans=0 seq1=0 for c in S: match c: case '0': seq1>>=1 ans+=seq1 seq1<<=1 case '1': seq1+=1 print(ans)