{-# LANGUAGE OverloadedStrings #-}
module Main where

import Data.List
import Data.Bits
import Data.Char (digitToInt)
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust, fromMaybe)
import qualified Data.Map.Strict as M
import qualified Data.Vector.Unboxed as V
import qualified Data.Set as S


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

bcAsInt :: BC.ByteString -> Int
bcAsInt  = fst . fromJust . BC.readInt

readIntBC :: IO (Int, BC.ByteString)
readIntBC = do
    [a, b] <- BC.words <$> BC.getLine
    return (fst . fromJust . BC.readInt $ a, b)

bitSearch :: Int -> [[Bool]]
bitSearch keta = each <$> [0..2^keta - 1] where
    each :: Int -> [Bool]
    each bits = (\d -> shift bits (negate d) .&. 1 == 1) <$>  [0..(keta - 1)]

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las

fastPowerMod :: Int -> Int -> Int -> Int
fastPowerMod b 0 _ = 1
fastPowerMod b 1 modnum = b `mod` modnum
fastPowerMod b n modnum
            | even n = (fastPowerMod b (n `div` 2) modnum ^ 2) `mod` modnum
            | otherwise = (fastPowerMod b (n - 1) modnum * b) `mod` modnum

solve :: BC.ByteString -> Int
solve n = let
    numList = fmap digitToInt . BC.unpack $ n
    kanouseiList = bitSearch $ length numList - 1
    go kanousei = let
        (first:latter) = numList
        initial = (0, first)
        lst = zip kanousei latter
        inner (total, stack) (True, num) = (total + stack, num)
        inner (total, stack) (False, num) = (total, stack * 10 + num)
        (total, stack) = foldl' inner initial lst
        in
        total + stack
    in
    sum $ go <$> kanouseiList


main :: IO ()
main = do
    n <- BC.getLine
    print $ solve n


