You are given a string S consisting of digits between 1 and 9, inclusive.
You can insert the letter + into some of the positions (possibly none) between two letters in this string.
Here, + must not occur consecutively after insertion.
All strings that can be obtained in this way can be evaluated as formulas.
Evaluate all possible formulas, and print the sum of the results.

-----Constraints-----
 - 1 \leq |S| \leq 10
 - All letters in S are digits between 1 and 9, inclusive.

-----Input-----
The input is given from Standard Input in the following format:
S

-----Output-----
Print the sum of the evaluated value over all possible formulas.

-----Sample Input-----
125

-----Sample Output-----
176

There are 4 formulas that can be obtained: 125, 1+25, 12+5 and 1+2+5. When each formula is evaluated,
 - 125
 - 1+25=26
 - 12+5=17
 - 1+2+5=8
Thus, the sum is 125+26+17+8=176.

Difficulty: EASY

Solutions:
s = input()
total = 0
for i in range(len(s)):
	for j in range(len(s) - i):
		n = int(s[j:j + i + 1])
		if j == 0 or j == len(s) - i - 1:
			total += n * max([2 ** (len(s) - i - 2), 1])
		else:
			total += n * max([2 ** (len(s) - i - 3), 1])
print(total)


s = input()
ans = ''
for i in range(1 << len(s) - 1):
	ans += s[0]
	for j in range(len(s) - 1):
		if i >> j & 1:
			ans += ' '
		ans += s[j + 1]
	ans += ' '
print(sum(map(int, ans.split())))


s = input().strip()
ls = len(s)
total = 0
for i in range(1, ls + 1):
	for j in range(0, ls - i + 1):
		total += int(s[j:j + i]) * pow(2, max(0, j - 1) + max(0, ls - i - j - 1))
print(total)


S = input()
L = []
for i in range(len(S)):
	L.append(S[i])
n = len(S)
ans = []
for i in range(2 ** (n - 1)):
	obj = []
	for j in range(n - 1):
		if i >> j & 1:
			obj.append(j)
		else:
			obj.append(-1)
	s = ''
	s += L[0]
	for j in range(len(obj)):
		if obj[j] == -1:
			s += L[j + 1]
			continue
		else:
			s += '+'
			s += L[j + 1]
	idx = 0
	now = 0
	while True:
		if now == len(s) - 1:
			ans.append(int(s[idx:]))
			break
		if s[now] == '+':
			ans.append(int(s[idx:now]))
			idx = now + 1
			now = idx
		else:
			now += 1
print(sum(ans))


S = input()
l = len(S)
ans = 0
for i in range(l):
	for j in range(i + 1, l + 1):
		s = int(S[i:j])
		e = max(i - 1, 0) + max(l - j - 1, 0)
		ans += s * 2 ** e
print(ans)


N = str(int(input()))
total = 0
l = len(N) - 1
if l == 0:
	print(N)
else:
	for i in range(2 ** l):
		b = format(i, '0' + str(l) + 'b')
		subtotal = 0
		s = N[0]
		for j in range(len(b)):
			if int(b[j]):
				subtotal += int(s)
				s = N[j + 1]
			else:
				s += N[j + 1]
		subtotal += int(s)
		total += subtotal
	print(total)


S = input()
ans = []

def fn(s, arr):
	ans.append(int(s) + sum(map(int, arr)))
	for i in range(1, len(s)):
		fn(s[i:], arr + [s[:i]])
fn(S, [])
print(sum(ans))


s = input()
import itertools
l = [*itertools.accumulate(s)]
o = []
for b in range(1 << len(s) - 1):
	q = []
	p = 0
	for i in range(len(s) - 1):
		if b & 1 << i:
			q += (int(l[i][p:]),)
			p = i + 1
	c = l[-1][p:]
	c = c if c else 0
	q += (int(c),)
	o += (sum(q),)
print(sum(o))


S = input()
L = len(S)

def dfs(i, f):
	if i == L - 1:
		return sum(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 = input()
n = len(s)

def dfs(i, x):
	if i == n - 1:
		return sum(list(map(int, x.split('+'))))
	return dfs(i + 1, x + s[i + 1]) + dfs(i + 1, x + '+' + s[i + 1])
print(dfs(0, s[0]))


S = input()
n = len(S)
ans = 0
for bit in range(1 << n - 1):
	tmp = S[0]
	for i in range(n - 1):
		if bit & 1 << i:
			tmp += '+'
		tmp += S[i + 1]
	ans += sum(map(int, tmp.split('+')))
print(ans)


def dfs(i, f):
	if i == s - 1:
		return sum(map(int, f.split('+')))
	return dfs(i + 1, f + n[i + 1]) + dfs(i + 1, f + '+' + n[i + 1])
n = input()
s = len(n)
print(dfs(0, n[0]))


s = list(input())
ans = 0
for bit in range(1 << len(s) - 1):
	a = [int(s[0])]
	for i in range(len(s) - 1):
		if bit >> i & 1 == 1:
			a.append(int(s[i + 1]))
		else:
			a[-1] = 10 * a[-1] + int(s[i + 1])
	ans += sum(a)
print(ans)


s = input()

def dfs(i, f):
	global s_sum
	if i == len(s) - 1:
		s_sum += sum(map(int, f.split('+')))
	else:
		dfs(i + 1, f + '+' + s[i + 1])
		dfs(i + 1, f + s[i + 1])
s_sum = 0
dfs(0, s[0])
print(s_sum)


from itertools import product
s = input()
n = len(s)
ans = 0
for p in product([0, 1], repeat=n - 1):
	wk = s[0]
	index = 0
	for i in p:
		index += 1
		if i == 0:
			wk += s[index]
		else:
			ans += int(wk)
			wk = s[index]
	if wk != '':
		ans += int(wk)
print(ans)


s = input()
n = len(s)
a = [None] * n
a[0] = int(s[0])
for i in range(n - 1):
	a[i + 1] = a[i] * 10 + sum((int(j) for j in s[:i + 2])) * 2 ** i + int(s[i + 1]) * 2 ** i
print(a[n - 1])


S = input()
N = len(S)

def f(i, a):
	if i == N - 1:
		return sum(list(map(int, a.split('+'))))
	return f(i + 1, a + S[i + 1]) + f(i + 1, a + '+' + S[i + 1])
print(f(0, S[0]))


s = input()
n = len(s)
n -= 1
ans = 0
for i in range(1 << n):
	tmp = 0
	for j in range(n):
		if i >> j & 1:
			ans += int(s[tmp:j + 1])
			tmp = j + 1
	ans += int(s[tmp:])
print(ans)


S = input()
n = len(S)
ans = 0
for i in range(n):
	a = int(S[i])
	for j in range(n - i):
		ans += a * 10 ** j * 2 ** i * 2 ** max(0, n - i - j - 2)
print(ans)


def cal():
	s = input()
	(num, ans) = (len(s) - 1, 0)
	for i in range(2 ** num):
		(count0, count1) = (0, 0)
		for j in range(num):
			count1 += 1
			if i >> j & 1:
				ans += int(s[count0:count1])
				count0 = count1
		ans += int(s[count0:count1 + 1])
	print(ans)
cal()


S = input()
n = len(S)

def dfs(i, k):
	if i == n - 1:
		return sum(list(map(int, k.split('+'))))
	return dfs(i + 1, k + S[i + 1]) + dfs(i + 1, k + '+' + S[i + 1])
print(dfs(0, S[0]))


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


import itertools
n = input()
l = len(n)
ans = 0
for ope in itertools.product('_+', repeat=l - 1):
	num = n[0]
	for i in range(l - 1):
		if ope[i] == '+':
			num += n[i + 1]
		else:
			ans += int(num)
			num = n[i + 1]
	ans += int(num)
print(ans)


def dfs(i, f):
	if i == n - 1:
		return sum(list(map(int, f.split('+'))))
	return dfs(i + 1, f + a[i + 1]) + dfs(i + 1, f + '+' + a[i + 1])
a = input()
n = len(a)
print(dfs(0, a[0]))


s = 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)


from functools import reduce

def original_sum(X, init):
	goukei = 0
	if len(X) == 0:
		return sum(init)
	else:
		for i in range(len(X)):
			lstm = init.copy()
			num = int(reduce(lambda x, y: x + y, [str(x) for x in X[0:i + 1]]))
			lstm.append(num)
			Y = X[i + 1:len(X)].copy()
			goukei = goukei + original_sum(Y, lstm)
	return goukei
number = list(input())
init = []
print(original_sum(number, init))


s = input()
ans = 0
for i in range(2 ** (len(s) - 1)):
	t = 0
	for j in range(len(s) - 1):
		if i >> j & 1:
			ans += int(s[t:j + 1])
			t = j + 1
	ans += int(s[t:])
print(ans)


import sys

def input():
	return sys.stdin.readline().rstrip()

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def main():
	s = input()
	n = len(s)
	ans = 0
	for i in range(1 << n - 1):
		idx = [0]
		for j in range(n - 1):
			if i >> j & 1:
				idx.append(j + 1)
		idx.append(n)
		for j in range(1, len(idx)):
			ans += int(s[idx[j - 1]:idx[j]])
	print(ans)

def __starting_point():
	main()
__starting_point()


s = input()
l = len(s)
ans = 0
for i in range(l):
	a = max(0, i - 1)
	ans += sum([int(s[i:j]) * (1 << a) * (1 << max(0, l - j - 1)) for j in range(i + 1, l + 1)])
print(ans)


def dfs(i, sum1):
	if i == len(s):
		return sum(list(map(int, sum1.split('+'))))
	return dfs(i + 1, sum1 + '+' + s[i]) + dfs(i + 1, sum1 + s[i])
s = input()
print(dfs(1, s[0]))


s = list(map(int, list(input())))
n = len(s)
m = 0
for i in range(n):
	for j in range(n - i):
		m += s[i] * 2 ** i * 10 ** j * 2 ** max(n - i - j - 2, 0)
print(m)


s = input()
L = []
sigma = 0

def sprit_sum(string, sprit, num):
	nonlocal sigma
	for i in range(1, len(string) + num - sprit):
		str_front = string[:i]
		str_back = string[i:]
		L.append(int(str_front))
		if num < sprit:
			sprit_sum(str_back, sprit, num + 1)
		else:
			L.append(int(str_back))
			for x in L:
				sigma += x
			L.pop()
		L.pop()
for j in range(len(s)):
	sprit_sum(s, j + 1, 1)
sigma += int(s)
print(sigma)


S = input()
ans = 0

def dfs(s, sum_, n):
	if n == len(S) - 1:
		return int(s) + sum_
	return dfs(s + S[n + 1], sum_, n + 1) + dfs(S[n + 1], sum_ + int(s), n + 1)
print(dfs(S[0], 0, 0))


S = input()
num = len(S)
ans = 0
for bit in range(2 ** (num - 1)):
	f = S[0]
	for i in range(num - 1):
		if bit >> i & 1:
			f += '+'
		f += S[i + 1]
	ans += sum(map(int, f.split('+')))
print(ans)


s = input().strip()
l = len(s)
print(sum((sum((int(s[i:j]) * 2 ** max(0, l - j - 1) for j in range(i + 1, l + 1))) * 2 ** max(0, i - 1) for i in range(l))))


s = input()
l = len(s)
ans = 0
for i in range(2 ** (l - 1)):
	tmp = ''
	sum = 0
	for j in range(l - 1):
		tmp += s[j]
		if i >> j & 1:
			sum += int(tmp)
			tmp = ''
	sum += int(tmp + s[-1])
	ans += sum
print(ans)


(a, b, k) = (0, 0, 1)
for d in input():
	(a, b) = (2 * a + b, 10 * b + int(d) * k)
	k *= 2
print(a + b)


ss = input()
l = len(ss) - 1
ans = 0
for i in range(2 ** l):
	s = ss
	for j in reversed(range(l)):
		if i & 2 ** j > 0:
			s = s[:j + 1] + ' ' + s[j + 1:]
	num = list(map(int, s.split(' ')))
	ans += sum(num)
print(ans)


s = input()

def dfs(s):
	ans = int(s)
	for i in range(1, len(s)):
		ans += int(s[:i]) * (1 << len(s[i:]) - 1) + dfs(s[i:])
	return ans
ans = dfs(s)
print(ans)


from itertools import accumulate
S = [int(i) for i in input()]
N = len(S)
sac = [0] + list(accumulate(S))
ans = 0
for i in range(N):
	ans += int(sac[i] * 2 ** (i - 1) + 2 ** i * S[i]) * 10 ** (N - 1 - i)
print(ans)


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


printn = lambda x: print(x, end='')
inn = lambda : int(input())
inl = lambda : list(map(int, input().split()))
inm = lambda : map(int, input().split())
ins = lambda : input().strip()
DBG = True
BIG = 10 ** 18
R = 10 ** 9 + 7

def ddprint(x):
	if DBG:
		print(x)
s = ins()
n = len(s)
ans = 0
for i in range(2 ** (n - 1)):
	z = []
	head = 0
	for j in range(n - 1):
		if (i >> j) % 2 > 0:
			z.append(int(s[head:j + 1]))
			head = j + 1
	z.append(int(s[head:]))
	ans += sum(z)
print(ans)


S = input()
ans = 0
for i in range(2 ** (len(S) - 1)):
	ls = []
	index = 0
	for j in range(len(S) - 1):
		if i >> j & 1:
			ls.append(int(S[index:j + 1]))
			index = j + 1
	ls.append(int(S[index:]))
	ans += sum(ls)
print(ans)


s = input()
nums = []
f = '0' + str(len(s) - 1) + 'b'
for i in range(2 ** (len(s) - 1)):
	m = format(i, f)
	l = 0
	r = 0
	while r < len(m):
		if m[r] == '1':
			nums.append(s[l:r + 1])
			l = r + 1
		r += 1
	nums.append(s[l:r + 1])
print(sum(map(int, nums)))


from itertools import product
s = input()
n = len(s)
ans = 0
for lst in product(['x', ' '], repeat=n - 1):
	ss = ''
	for i in range(n - 1):
		ss += s[i] + str(lst[i])
	ss += s[-1]
	ss = ss.replace('x', '')
	temp = [int(x) for x in ss.split()]
	ans += sum(temp)
print(ans)


s = input()
ans = 0
for i in range(0, len(s)):
	for j in range(i + 1, len(s) + 1):
		ans += int(s[i:j]) * max(1, 2 ** (i - 1)) * max(1, 2 ** (len(s) - j - 1))
print(ans)


num = int(input())

def the_algorithm(num):
	ary = list(str(num))
	sum = 0
	for bit in range(1 << len(ary) - 1):
		tmp = [ary[0]]
		for i in range(len(ary) - 1):
			mask = 1 << i
			if bit & mask:
				tmp.append(ary[i + 1])
			else:
				tmp[-1] = tmp[-1] + ary[i + 1]
		for i in tmp:
			sum += int(i)
	return sum
print(the_algorithm(num))


s = input()
l = len(s) - 1
ans = 0
for j in range(2 ** l):
	L = 0
	for i in range(l):
		if j >> i & 1 == 1:
			m = s[L:i + 1]
			ans += int(m)
			L = i + 1
	ans += int(s[L:])
print(ans)


def dfs(i, sall):
	if i == lenS:
		return sall
	return dfs(i + 1, sall + '+' + s[i]) + '+' + dfs(i + 1, sall + s[i])
s = input()
lenS = len(s)
print(sum(map(int, dfs(1, s[0]).split('+'))))


S = input()
n = len(S) - 1
result = 0
for i in range(2 ** n):
	sum = 0
	temp = ''
	for j in range(n):
		temp += S[j]
		if i >> j & 1:
			sum += int(temp)
			temp = ''
	sum += int(temp + S[-1])
	result += sum
print(result)


S = input()
ans = 0
for i in range(len(S)):
	for j in range(i + 1):
		ans += int(S[-(i + 1)]) * 10 ** j * 2 ** (len(S) - 1) // 2 ** min(i, j + 1)
print(ans)


def s(d, k, i, c):
	if i == len(d):
		return c + int(k)
	return s(d, d[i], i + 1, int(k) + c) + s(d, k + d[i], i + 1, c)
d = [x for x in input()]
print(s(d, d[0], 1, 0))


n = input()
ans = 0
for i in range(2 ** (len(n) - 1)):
	l = [0]
	for j in range(len(n) - 1):
		if i >> j & 1:
			l.append(j + 1)
	l.append(len(n))
	for j in range(len(l) - 1):
		ans += int(n[l[j]:l[j + 1]])
print(ans)


s = input()
dp = [0] * len(s)
dp[0] = int(s[0])
for i in range(1, len(s)):
	dp[i] = int(s[:i + 1]) + sum((dp[j - 1] + int(s[j:i + 1]) * 2 ** (j - 1) for j in range(1, i + 1)))
print(dp[-1])


S = input()
N = len(S)
ans = 0
for sep in range(2 ** (N - 1)):
	p = 0
	for i in range(N):
		if sep >> i & 1 or i == N - 1:
			ans += int(S[p:i + 1])
			p = i + 1
print(ans)


s = input()
n = len(s)
ans = 0
for i in range(2 ** (n - 1)):
	k = 0
	num_list = []
	for j in range(n):
		if i >> j & 1:
			num = s[k:j + 1]
			k = j + 1
			num_list.append(int(num))
	num = s[k:n + 1]
	num_list.append(int(num))
	ans += sum(num_list)
print(ans)


g = lambda s: max(1, sum((g(s[i + 1:]) for i in range(len(s)))))
f = lambda s: sum((int(s[:i]) * g(s[i:]) + f(s[i:]) for i in range(1, len(s) + 1)))
print(f(input()))


import copy
s = input()
l = len(s)
ans = 0
if l == 1:
	ans += int(s)
	print(ans)
else:
	for i in range(2 ** (l - 1)):
		t = copy.deepcopy(s)
		f = []
		ch = 0
		for j in range(l - 1):
			if i >> j & 1:
				t = t[:j + 1 + ch] + '+' + t[j + 1 + ch:]
				ch += 1
		if '+' in t:
			y = list(map(int, t.split('+')))
			for u in y:
				ans += u
		else:
			ans += int(t)
	print(ans)


n = input()
L = []
s = 0
for i in range(len(n)):
	L.append(int(n[i]))
for i in range(len(n)):
	s += (sum(L[0:i]) * 2 ** (i - 1) + L[i] * 2 ** i) * 10 ** (len(n) - i - 1)
print(int(s))


a = input()
n = len(a)
ans = 0
for i in range(2 ** (n - 1)):
	f = a[0]
	for j in range(n - 1):
		if i >> j & 1:
			f += '+'
		f += a[j + 1]
	ans += sum(map(int, f.split('+')))
print(ans)


S = input()
if len(S) == 1:
	print(S)
else:

	def bfs(i, j, k):
		if i == len(S) - 1:
			return k + int(S[j:])
		return bfs(i + 1, i + 1, k + int(S[j:i + 1])) + bfs(i + 1, j, k)
	bns = bfs(0, 0, 0)
	print(bns)


S = input()
f = lambda x: 2 ** (x - 1) if x > 0 else 1
lenS = len(S)
ans = 0
for i in range(1, lenS + 1):
	for j in range(lenS - i + 1):
		ans += int(S[j:j + i]) * f(j) * f(lenS - j - i)
print(ans)


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


s = list(input())
n = len(s) - 1

def dfs(x, y):
	ans = 0
	if x == n:
		return sum(list(map(int, ''.join(y).split('+'))))
	else:
		return dfs(x + 1, y + '+' + s[x + 1]) + dfs(x + 1, y + s[x + 1])
print(dfs(0, s[0]))


S = input()
(a, b) = (0, int(S[0]))
for i in range(1, len(S)):
	d = int(S[i])
	a = 2 * a + b
	b = 10 * b + 2 ** i * d
print(a + b)


s = input()
sm = 0
for i in range(1 << len(s) - 1):
	j = 0
	st = 0
	while j < len(s):
		if i >> j & 1 == 1:
			sm += int(s[st:j + 1])
			st = j + 1
		j += 1
	sm += int(s[st:])
print(sm)


S = input()
N = len(S)
ans = 0
for i in range(2 ** (N - 1)):
	Bit = list((i + 1 for i in range(N - 1)))
	for j in range(N - 1):
		if i >> j & 1:
			Bit[j] = 0
	Bit = [b for b in Bit if b > 0]
	L = 0
	for b in Bit:
		ans += int(S[L:b])
		L = b
	ans += int(S[L:])
print(ans)


s = input()
ans = 0
for bit in range(0, 1 << len(s) - 1):
	opr = []
	for i in range(len(s) - 1):
		opr.append('水着' if bit >> i & 1 == 1 else 'ワンピース')
	exp = [s[0]]
	for i in range(len(opr)):
		if opr[i] == 'ワンピース':
			exp[-1] += s[i + 1]
		elif opr[i] == '水着':
			exp.append(s[i + 1])
	ans += sum(list(map(int, exp)))
print(ans)


S = list(input())
N = len(S)
ans = 0
for i in range(2 ** (N - 1)):
	l = 0
	for j in range(N - 1):
		if i >> j & 1:
			ans += int(''.join(S[l:j + 1]))
			l = j + 1
	ans += int(''.join(S[l:]))
print(ans)


import math
import collections
from itertools import product
ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(map(int, input().split()))
s = list(input())
n = len(s)
ans = 0
for p in product((0, 1), repeat=n):
	total = 0
	for i in range(n):
		if p[i] == 1:
			ans += total
			total = 0
		else:
			total = total * 10 + int(s[i])
	ans += total
print(ans)


s = input()
n = len(s)

def dfs(now, total, i):
	if i == n:
		return total + now
	else:
		res = 0
		res += dfs(now * 10 + int(s[i]), total, i + 1)
		res += dfs(int(s[i]), total + now, i + 1)
		return res
print(dfs(int(s[0]), 0, 1))


S = input()
n = len(S)

def kei(i, f):
	if i == n - 1:
		return sum(list(map(int, f.split('+'))))
	return kei(i + 1, f + S[i + 1]) + kei(i + 1, f + '+' + S[i + 1])
print(kei(0, S[0]))


S = input()
l = len(S)
ans = int(S[-1]) * 2 ** (l - 1)
for i in range(1, l):
	a = int(S[-i - 1])
	for j in range(i + 1):
		ans += a * 10 ** j * 2 ** (l - min(j, i - 1) - 2)
print(ans)


s = input()
n = len(s)
l = [0]
for i in range(n):
	sm = 0
	for j in range(i + 1):
		sm += l[j] + int(s[j:i + 1]) * 2 ** max(j - 1, 0)
	l.append(sm)
print(sm)


s = input()
n = len(s) - 1
ans = 0
for i in range(2 ** n):
	op = [0] * n
	for j in range(n):
		if i >> j & 1:
			op[j] = 1
	t = s[0]
	for j in range(1, n + 1):
		if op[j - 1] == 1:
			t += '+' + s[j:j + 1]
		else:
			t += s[j:j + 1]
	ans += sum(list(map(int, t.split('+'))))
print(ans)


S = input()
n = len(S)
ans = 0
for i in range(2 ** (n - 1)):
	tmp = 0
	t = 0
	for j in range(n - 1):
		if i >> j & 1:
			tmp += int(S[t:j + 1])
			t = j + 1
	tmp += int(S[t:])
	ans += tmp
print(ans)


S = input()
l = len(S)
ans = 0
for i in range(l):
	for j in range(i + 1, l + 1):
		temp = int(S[i:j])
		ans += temp * max(1, pow(2, i - 1)) * max(1, pow(2, l - j - 1))
print(ans)


from itertools import product
S = input()
length = len(S)
ans = 0
for lst in product(['+', ''], repeat=length - 1):
	mystr = ''
	for i in range(length - 1):
		mystr += S[i] + lst[i]
	mystr += S[-1]
	mylist = [int(x) for x in mystr.split('+')]
	ans += sum(mylist)
print(ans)


S = input()
N = len(S)
ans = 2 ** (N - 1) * int(S[-1])
for i in range(1 << N - 1):
	res = 1
	for j in range(N - 1):
		if (i >> j) % 2 == 1:
			res *= 10
		else:
			res = 1
		ans += res * int(S[N - 2 - j])
print(ans)


S = input()
ans = 0
for b in range(2 ** (len(S) - 1)):
	x = int(S[0])
	for i in range(1, len(S)):
		if b % 2:
			ans += x
			x = 0
		else:
			x *= 10
		x += int(S[i])
		b //= 2
	ans += x
print(ans)


def bfs(s: str, n: int, i: int, j: int, k: int):
	return k + int(s[j:]) if i == n - 1 else bfs(s, n, i + 1, i + 1, k + int(s[j:i + 1])) + bfs(s, n, i + 1, j, k)
s = input()
n = len(s)
print(bfs(s, n, 0, 0, 0))


s = input()
s_sum = []
for i in range(2 ** (len(s) - 1)):
	sj = 0
	a = 0
	for j in range(len(s) - 1):
		if i >> j & 1:
			a += int(s[sj:j + 1])
			sj = j + 1
	a += int(s[sj:])
	s_sum.append(a)
print(sum(s_sum))


def hojyu(a):
	if len(a) != N:
		return '0' * (N - len(a)) + a
	else:
		return a
S = input()
N = len(S) - 1
R = list()
ans = 0
for i in range(2 ** N):
	s = str(bin(i)[2:])
	s = hojyu(s)
	b = 0
	mae = 0
	for k in range(len(s)):
		if s[k] == '1':
			b += int(S[mae:k + 1])
			mae = k + 1
	b += int(S[mae:])
	ans += b
print(ans)


S = input()
len_S = len(S)
ans = 0
left = 0
is_plus = [0] * (len_S - 1)
for i in range(2 ** (len_S - 1)):
	left = 0
	for j in range(len_S - 1):
		(i, mod) = divmod(i, 2)
		if mod == 1:
			ans += int(S[left:j + 1])
			left = j + 1
	ans += int(S[left:len_S])
print(ans)


s = input()
l = len(s)

def dfs(n):
	if n == l:
		return [0]
	ret = []
	for i in range(n + 1, l + 1):
		ret += [int(s[n:i]) + j for j in dfs(i)]
	return ret
print(sum(dfs(0)))


s = input()
n = len(s) - 1
res = 0
for i in range(1 << n):
	num_str = s[0]
	for j in range(n):
		if i >> j & 1 == 0:
			num_str += s[j + 1]
		else:
			res += int(num_str)
			num_str = s[j + 1]
	res += int(num_str)
print(res)


s = input()
n = len(s)
ans = 0
for i in range(2 ** (n - 1)):
	t = []
	x = i
	for j in range(n - 1):
		t.append(s[j])
		if x % 2 != 0:
			t.append('+')
		x = x // 2
	t.append(s[-1])
	m = 0
	for i in t:
		if i != '+':
			m *= 10
			m += int(i)
		else:
			ans += m
			m = 0
	ans += m
print(ans)


S = input()
N = len(S) - 1
ans = 0
for x in range(2 ** N):
	pvj = 0
	for j in range(N):
		if x >> j & 1:
			ans += int(S[pvj:j + 1])
			pvj = j + 1
	ans += int(S[pvj:N + 1])
print(ans)


s = input()
n = len(s)

def f(i, t):
	if i == n - 1:
		return sum(list(map(int, t.split('+'))))
	return f(i + 1, t + s[i + 1]) + f(i + 1, t + '+' + s[i + 1])
print(f(0, s[0]))


s = [int(c) for c in input()]
n = len(s)
dp = [0] * n
dp2 = [0] * n
dp[0] = s[0]
dp2[0] = s[0]
for i in range(1, n):
	dp2[i] = dp2[i - 1] * 10 + s[i] * 2 ** i
	dp[i] = dp2[i] + 2 * dp[i - 1] - dp2[i - 1]
print(dp[n - 1])


S = input()
ans = 0

def helper(cur, res):
	global ans
	if res == '':
		ans += cur
	for i in range(1, len(res) + 1):
		helper(cur + int(res[:i]), res[i:])
helper(0, S)
print(ans)


S = input()
ans = 0
for i in range(2 ** (len(S) - 1)):
	l = 0
	for j in range(len(S) - 1):
		if i >> j & 1:
			ans += int(S[l:j + 1])
			l = j + 1
	ans += int(S[l:])
print(ans)


s = input()
n = len(s)

def dfs(l, r):
	if r == n:
		return int(s[l:r])
	return int(s[l:r]) * pow(2, n - r - 1) + dfs(r, r + 1) + dfs(l, r + 1)
print(dfs(0, 1))


s = input()
n = len(s)
a = 0
for i in range(n):
	d = int(s[i])
	for k in range(n - i):
		a += 2 ** i * int(2 ** (k - 1) + 0.5) * 10 ** (n - i - k - 1) * d
print(a)


N = input()
L = []
S = 0
for i in range(len(N)):
	L.append(int(N[i]))
for i in range(len(N)):
	S += (sum(L[0:i]) * 2 ** (i - 1) + L[i] * 2 ** i) * 10 ** (len(N) - i - 1)
print(int(S))


n = list(map(int, input()))
ans = 0
ind = len(n) - 1
for i in range(len(n)):
	ans += 10 ** i * (n[-1] * 2 ** ind + sum(n[:-1]) * 2 ** (ind - 1))
	n = n[:-1]
	ind = len(n) - 1
print(int(ans))


class Combination:

	def __init__(self, n, mod):
		self.n = n
		self.mod = mod
		self.fac = [1 for i in range(self.n + 1)]
		self.finv = [1 for i in range(self.n + 1)]
		for i in range(2, self.n + 1):
			self.fac[i] = self.fac[i - 1] * i % self.mod
			self.finv[i] = self.finv[i - 1] * pow(i, -1, self.mod) % self.mod

	def comb(self, n, m):
		return self.fac[n] * (self.finv[n - m] * self.finv[m] % self.mod) % self.mod

def iparse():
	return list(map(int, input().split()))

def __starting_point():
	s = input()
	ans = 0
	for i in range(1 << len(s) - 1):
		prev = 0
		for j in range(len(s) - 1):
			if i >> j & 1 == 1:
				tmp = s[prev:j + 1]
				ans += int(tmp)
				prev = j + 1
		ans += int(s[prev:])
	print(ans)
__starting_point()


def f(s, t):
	if t == '':
		return sum(map(int, s.split('+')))
	else:
		return f(s + t[0], t[1:]) + f(s + '+' + t[0], t[1:])
S = input()
print(f(S[0], S[1:]))


S = input()
ans = 0
for i in range(2 ** (len(S) - 1)):
	tmp = int(S[0])
	for j in range(1, len(S)):
		if i & 1 == 1:
			ans += tmp
			tmp = int(S[j])
		else:
			tmp = tmp * 10 + int(S[j])
		i = i >> 1
	ans += tmp
print(ans)


S = input()

def f(i, s):
	if i == len(S) - 1:
		return sum(map(int, s.split('+')))
	else:
		return f(i + 1, s + S[i + 1]) + f(i + 1, s + '+' + S[i + 1])
print(f(0, S[0]))


s = input()
all_s = []

def ss(index, perm):
	if index == len(s):
		all_s.append(perm)
	else:
		perm1 = [i for i in perm]
		perm1[-1] += s[index]
		ss(index + 1, perm1)
		perm2 = [i for i in perm]
		perm2.append(s[index])
		ss(index + 1, perm2)
ss(1, [s[0]])
all_sum = 0
for way in all_s:
	tmp = 0
	for n in way:
		tmp += int(n)
	all_sum += tmp
print(all_sum)


def cal(d, i, k, total):
	if i == len(d):
		return total + int(k)
	return cal(d, i + 1, d[i], total + int(k)) + cal(d, i + 1, k + d[i], total)
d = [x for x in input()]
print(cal(d, 1, d[0], 0))


S = input()
n = len(S)
ans = 0
for paint in range(2 ** (n - 1)):
	temp_S = S[0]
	for i in range(n - 1):
		if paint >> i & 1 == 1:
			temp_S += '+'
		temp_S += S[i + 1]
	ans += sum(map(int, temp_S.split('+')))
print(ans)


s = input()
l = len(s)

def dfs(i, f):
	if i == l - 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 = input()
ans = 0
for i in range(2 ** (len(s) - 1)):
	r = 0
	d = '0' * 10 + bin(i)
	for j in range(len(s) - 1):
		if d[-j - 1] == '1':
			ans += int(s[r:j + 1])
			r = j + 1
	ans += int(s[r:])
print(ans)


n = str(input())
len_n = len(n) - 1
ans = 0
total = 0
for i in range(2 ** len_n):
	temp = n[0]
	for j in range(len_n):
		if i >> j & 1:
			temp += '+'
		temp += n[j + 1]
	total = list(map(int, temp.split('+')))
	ans += sum(total)
print(ans)


S = [int(n) for n in input()]
l = len(S)
ans = 0
for i in range(l):
	for j in range(l - i):
		if i + j == l - 1:
			t = 1
		else:
			t = 2
		ans += S[i] * 10 ** j * 2 ** (l - j - t)
print(ans)