Олимпиадный тренинг

Задача 38653. Lots of formulas


You are given a string S consisting of numbers from 1 to 9 inclusive. You can insert the character + at some positions (perhaps none) between two digits in this string. Here, the + character must not appear consecutively after insertion (i.e., there must not be two or more characters in a row). All rows that can be obtained in this way can be evaluated as formulas. Evaluate all possible formulas and print the sum of the results from all possible formulas.

Input
The input is a non-empty string S, consisting of numbers from 1 to 9 inclusive. The string is limited to 10 characters.

Imprint
Print the sum of the results obtained by evaluating all possible formulas.
 

 

Examples
# Input Output Explanation
1 125 176 There are 4 formulas in total: 125, 1 + 25, 12 + 5 and 1 + 2 + 5.
Result after evaluating each formula:
125
1 + 25 = 26
12 + 5 = 17
1 + 2 + 5 = 8
So the sum is 125 + 26 + 17 + 8 = 176.
2 9999999999 12656242944