program main
  implicit none
  character(10) :: s, q
  integer(8) :: n, i, ans, k, j, x
  integer, allocatable :: l(:)
  character(10), allocatable :: r(:)

  read(*,*) s
  n = len_trim(s)
  allocate(l(n-1))
  allocate(r(0:2**(n-1)-1))

  ans = 0
  do i = 0, 2**(n-1) -1
     q = ''
     do j = 1, n-1
        l(j) = mod(i,2**(n-j)) / 2**(n-j-1)
        write(q(j:j),'(i1)') l(j)
     end do
     r(i) = q
  end do
  
  do i = 0, 2**(n-1) -1
     q = r(i)
     k = 1
     do j = 1, n-1
        if(q(j:j) == '1')then
           read(s(k:j),'(i10)') x
           ans = ans + x
           k = j + 1
        end if
     end do
     read(s(k:n),'(i10)') x
      ans = ans + x
  end do
  write(*,*) ans
end program main

