import copy

S=eval(input())

lst=[]

def Sum(l,S):

    if S=="A":

        return sum(l)

    a=l.pop()

    x=copy.copy(l)

    x.append(a*10+int(S[0]))

    y=copy.copy(l)

    y.extend([a,int(S[0])])

    return Sum(x,S[1:])+Sum(y,S[1:])

S+="A"

lst.append(int(S[0]))

print((Sum(lst,S[1:])))
from collections import deque

S=eval(input())

queue=deque()

lst=[]

lst.append([0,0])

for i in range(0,len(S)):

    l=len(lst)

    for _ in range(l):

        x,y=lst.pop(0)

        lst.append([x,y*10+int(S[i])])#plus

        lst.append([x+y*10+int(S[i]),0])

l=len(lst)

for _ in range(l):

    x,y=lst.pop(0)

    lst.append(x+y)

print((int(sum(lst)/2)))

import copy

S = eval(input())
lst = []


def Sum(l, S):
    if S == "A":
        return sum(l)
    a = l.pop()
    x = copy.copy(l)
    x.append(a * 10 + int(S[0]))
    y = copy.copy(l)
    y.extend([a, int(S[0])])
    return Sum(x, S[1:]) + Sum(y, S[1:])


S += "A"
lst.append(int(S[0]))
print((Sum(lst, S[1:])))

from collections import deque

S = eval(input())
queue = deque()
lst = []
lst.append([0, 0])
for i in range(0, len(S)):
    l = len(lst)
    for _ in range(l):
        x, y = lst.pop(0)
        lst.append([x, y * 10 + int(S[i])])  # plus
        lst.append([x + y * 10 + int(S[i]), 0])
l = len(lst)
for _ in range(l):
    x, y = lst.pop(0)
    lst.append(x + y)
print((int(sum(lst) / 2)))

-import copy +from collections import deque +queue = deque() - - -def Sum(l, S): -    if S == "A": -        return sum(l) -    a = l.pop() -    x = copy.copy(l) -    x.append(a * 10 + int(S[0])) -    y = copy.copy(l) -    y.extend([a, int(S[0])]) -    return Sum(x, S[1:]) + Sum(y, S[1:]) - - -S += "A" -lst.append(int(S[0])) -print((Sum(lst, S[1:]))) +lst.append([0, 0]) +for i in range(0, len(S)): +    l = len(lst) +    for _ in range(l): +        x, y = lst.pop(0) +        lst.append([x, y * 10 + int(S[i])])  # plus +        lst.append([x + y * 10 + int(S[i]), 0]) +l = len(lst) +for _ in range(l): +    x, y = lst.pop(0) +    lst.append(x + y) +print((int(sum(lst) / 2)))