let ans s =
  let len = String.length s - 1 in
  let all = 1 lsl len in
  let rec f ret i =
    if i = all then ret
    else
      let ioc n = int_of_char n - int_of_char '0' in
      let rec g ret j x k =
        if j = len then ret+x
        else if (k land 1) = 1 then g (ret+x) (j+1) (ioc s.[j+1]) (k lsr 1)
        else g ret (j+1) (10 * x + ioc s.[j+1]) (k lsr 1)
      in f (ret + g 0 0 (ioc s.[0]) i) (i+1)
  in f 0 0;;

Scanf.scanf "%s" (fun s -> print_int (ans s))
