s = eval(input())

n = len(s)



ans = 0



for bit in range(1 << (n - 1)):

    f = s[0]



    for i in range(n - 1):

        if bit & (1 << i):

            f += "+"

        f += s[i + 1]



    ans += sum(map(int, f.split("+")))



print(ans)
s = eval(input())

n = len(s)





def dfs(i, f):

    if i == n - 1:

        return sum(list(map(int, f.split("+"))))



    return dfs(i + 1, f + s[i + 1]) + dfs(i + 1, f + "+" + s[i + 1])





print((dfs(0, s[0])))
s = eval(input())
n = len(s)
ans = 0
for bit in range(1 << (n - 1)):
    f = s[0]
    for i in range(n - 1):
        if bit & (1 << i):
            f += "+"
        f += s[i + 1]
    ans += sum(map(int, f.split("+")))
print(ans)

s = eval(input())
n = len(s)


def dfs(i, f):
    if i == n - 1:
        return sum(list(map(int, f.split("+"))))
    return dfs(i + 1, f + s[i + 1]) + dfs(i + 1, f + "+" + s[i + 1])


print((dfs(0, s[0])))

-ans = 0 -for bit in range(1 << (n - 1)): -    f = s[0] -    for i in range(n - 1): -        if bit & (1 << i): -            f += "+" -        f += s[i + 1] -    ans += sum(map(int, f.split("+"))) -print(ans) + + +def dfs(i, f): +    if i == n - 1: +        return sum(list(map(int, f.split("+")))) +    return dfs(i + 1, f + s[i + 1]) + dfs(i + 1, f + "+" + s[i + 1]) + + +print((dfs(0, s[0])))