let array_of_string s = Array.init (String.length s) (fun i -> s.[i])

let () =
  read_line ()
  |> array_of_string
  |> Array.to_list
  |> List.map (fun c -> Char.code c - Char.code '0')
  |> (fun (d :: n) -> List.fold_left (fun candidates d ->
      List.concat @@ List.map (fun (sum, x) -> [(sum + x, d); (sum, 10 * x + d)]) candidates) [(0, d)] n)
  |> List.map (fun (sum, x) -> sum + x)
  |> List.fold_left ( + ) 0
  |> Printf.printf "%d\n"