let inp_list = fun () ->
  List.map int_of_string (Str.split (Str.regexp "") (input_line stdin))
    
type op =
  | Plus
  | Cons

let rec list_all : int -> 'a list -> 'a list list  = fun n ol ->
  if n > 0 then
    List.fold_right (fun l ans ->
        List.fold_right
          (fun o xs ->
             (o :: l) :: xs)
          ol ans)
      (list_all (n - 1) ol) []
  else
    [[]]

let removeCons l ops =
  let rec loop =
    (function
      | (x1 :: x2 :: xs, o :: os) ->
        (match o with
           Plus ->
           let (ans_xxs, ans_os) = (loop (x2 :: xs, os)) in
           (x1 :: ans_xxs, o :: ans_os)
         | Cons -> loop (10 * x1 + x2 :: xs, os))
      | ([x], _) -> ([x],[])
      | _ -> failwith "Something happend in removeCons")
  in
  loop (l, ops)  

let sum = List.fold_left (fun s x -> s + x) 0

let ic c = int_of_char c - int_of_char '0' 

let () =
  let l = inp_list () in
  let n = List.length l in
  let ops_lists = list_all (n - 1) [Plus; Cons] in
  let rec solve = function
      [] -> 0
    | ops :: opss ->
      let (l' , _) = removeCons l ops in
      sum l' + solve opss
  in
  let ans = solve ops_lists
  in
  print_int ans;
  print_newline ()
