let () =
  let v = Scanf.scanf "%d" (fun v->v) in
  let rec loop l n =
    if n = 0 then l else loop (n mod 10 :: l) (n/10)
  in
  let l = loop [] v in
  let l = List.fold_left (fun l d ->
    match l with
    | [] -> [0,d]
    | l -> List.fold_left (fun l (sum, x) ->
             (sum + x, d)::(sum, 10 * x + d)::l
           ) [] l
  ) [] l in
  let r = List.fold_left (fun r (sum, x) -> r + sum + x) 0 l in
  Printf.printf "%d\n" r
