import java.security.InvalidParameterException

data class LList(val value: Int, val next: LList?) {
    companion object {
        fun fromIntList(nums: List<Int>): LList {

            var list: LList? = null

            nums.reversed().forEach { num ->
                list = LList(num, list)
            }

            val result = list

            if (result == null) {
                throw InvalidParameterException("empty")
            }

            return result
        }
    }
}


fun main(args: Array<String>) {
    val nums: List<Int> = readLine()!!.trim().map {it.toString().toInt()}

    val numList = LList.fromIntList(nums)

    val total: Long = sumNums(numList, 0, 0)

    println(total)
}

fun sumNums(cur: LList, curTotal: Long, pending: Long): Long {

    if (cur.next == null) {
        return curTotal + pending * 10 + cur.value
    }

    val sum1: Long = sumNums(cur.next, curTotal + pending * 10 + cur.value, 0)
    val sum2: Long = sumNums(cur.next, curTotal, pending * 10 + cur.value)

    return sum1 + sum2
}