let rec solve = function
  | 0 -> [[0]]
  | s ->
      List.concat
        (List.map
          (fun (h :: t) ->
            [ s mod 10 :: h :: t; 10 * h + s mod 10 :: t ])
          (solve (s / 10)))

let () = Scanf.scanf "%d\n" (fun s ->
  solve s
  |> List.map (List.fold_left ( + ) 0)
  |> List.fold_left ( + ) 0
  |> (fun s -> s / 2)
  |> Printf.printf "%d\n")
