import Control.Applicative
import Text.Printf
import Debug.Trace

solve :: [Integer] -> Integer
solve [] = 0
solve [x] = x
solve (x:xs) = x*(2^((length xs) - 1)) + (solve xs) + (solve ((10*x+(xs!!0)):(tail xs)))

solve_sub :: Int->[Integer] -> Integer
solve_sub n [] = 0
solve_sub n [x] = x*2^n
solve_sub n (x:xs) = x*(2^n)*10^(length xs) + (1-5^(length xs))`div`(1-5)*x*2^(length xs - 1 + n) + (solve_sub (n+1) xs)
  
solve_ :: [Integer] -> Integer
solve_ l = solve_sub 0 l 

listize :: Integer->[Integer]
listize 0 = []
listize n = (listize $ n`div`10)++[(n`mod`10)]

main :: IO()
main = do
  n <- readLn
  -- O(2^N)
  --printf "%d\n" $ solve $ listize n
  -- O(N)
  printf "%d\n" $ solve $ listize n
