(* O(2^|s|) *)
let s = read_line ()
let ds = Array.to_list @@ Array.init (String.length s) @@ fun i -> Char.code s.[i] - 48
let rec f sum n = function
| [] -> sum + n
| d :: r -> f (sum + n) d r + f sum (10 * n + d) r
let _ = f 0 (List.hd ds) (List.tl ds) |> Printf.printf "%d\n"