import itertools

s = eval(input())

n = len(s)

ans=0

for op in itertools.product(["+",""],repeat=n-1):

  tmp=""

  for i in range(n-1):

    tmp+=s[i]+op[i]

  ans+=eval(tmp+s[-1])

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

n = len(s)-1

ans=0

for i in range(1 << n):

  k=0

  # print(bin(i))

  for j in range(n):

    # print("","j=",j,bin(i>>j),True if (i>>j)&1 else False,s[k:j+1])

    if i>>j&1 == 0:

      continue

    else:

      ans += int(s[k:j+1])

      k=j+1

  ans += int(s[k:])

print(ans)
import itertools

s = eval(input())
n = len(s)
ans = 0
for op in itertools.product(["+", ""], repeat=n - 1):
    tmp = ""
    for i in range(n - 1):
        tmp += s[i] + op[i]
    ans += eval(tmp + s[-1])
print(ans)

s = eval(input())
n = len(s) - 1
ans = 0
for i in range(1 << n):
    k = 0
    # print(bin(i))
    for j in range(n):
        # print("","j=",j,bin(i>>j),True if (i>>j)&1 else False,s[k:j+1])
        if i >> j & 1 == 0:
            continue
        else:
            ans += int(s[k : j + 1])
            k = j + 1
    ans += int(s[k:])
print(ans)

-import itertools - -n = len(s) +n = len(s) - 1 -for op in itertools.product(["+", ""], repeat=n - 1): -    tmp = "" -    for i in range(n - 1): -        tmp += s[i] + op[i] -    ans += eval(tmp + s[-1]) +for i in range(1 << n): +    k = 0 +    # print(bin(i)) +    for j in range(n): +        # print("","j=",j,bin(i>>j),True if (i>>j)&1 else False,s[k:j+1]) +        if i >> j & 1 == 0: +            continue +        else: +            ans += int(s[k : j + 1]) +            k = j + 1 +    ans += int(s[k:])