while True:
try:
n = int(input())
ans = 0
i = 1
while n:
ans += n % 10 * (2 ** i - 1)
n //= 10
i += 1
print(ans)
except:
break

while True:
try:
n = int(input())
ans = 0
i = 1
while n:
ans += n % 10 * (2 ** i - 1)
n //= 10
i += 1
print(ans)
except:
break