s = eval(input())

n = len(s)



ans = 0





for i in range(2**(n - 1)):

    a = ""

    for j in range(n-1):

        if (i >> j)& 1 == 1:

            a += s[j] + '+'

        else:

            a += s[j]

    a += s[-1]

    ans += eval(a)



print(ans)
S = eval(input())

N = len(S)



ans = 0

for i in range(1<<N-1):

    p = 0

    for j in range(N-1):

        if i >> j & 1:

            ans += int(S[p:j+1])

            p = j + 1

    ans += int(S[p:])

print(ans)
s = eval(input())
n = len(s)
ans = 0
for i in range(2 ** (n - 1)):
    a = ""
    for j in range(n - 1):
        if (i >> j) & 1 == 1:
            a += s[j] + "+"
        else:
            a += s[j]
    a += s[-1]
    ans += eval(a)
print(ans)

S = eval(input())
N = len(S)
ans = 0
for i in range(1 << N - 1):
    p = 0
    for j in range(N - 1):
        if i >> j & 1:
            ans += int(S[p : j + 1])
            p = j + 1
    ans += int(S[p:])
print(ans)

-s = eval(input()) -n = len(s) +S = eval(input()) +N = len(S) -for i in range(2 ** (n - 1)): -    a = "" -    for j in range(n - 1): -        if (i >> j) & 1 == 1: -            a += s[j] + "+" -        else: -            a += s[j] -    a += s[-1] -    ans += eval(a) +for i in range(1 << N - 1): +    p = 0 +    for j in range(N - 1): +        if i >> j & 1: +            ans += int(S[p : j + 1]) +            p = j + 1 +    ans += int(S[p:])