import Data.List
import Data.Bits
main = mapM_ (print . solve) . lines =<< getContents
solve::String->Int
solve s = sum . zipWith f [0..] . tails $ s where
  n = length s
  f i = sum . zipWith g [1..] . tail . inits where
    g k t = read t * h i * h (n-i-k)
h = shiftL 1 . max 0 . subtract 1