Mr. Masud is a superstitious executive of an administrative office in Wadia, and you have to bribe him to provide you with certain services. But the problem is, his superstitions are always a bit unconventional. That is the reason he is popularly known as "Ulta Masud." Usually, people consider the number 7 as lucky. But being an unconventional guy, Masud considers this an unlucky digit. So in his bribe invoices, he maintains all the transaction amounts in a manner where he doesn't use the number 7 at all. So he counts numbers like this: 0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, …
Now, you need some of the services mentioned earlier from him, and he has sent you a list of the prices for those services. But the costs are written in his weird number system that excludes the digit 7. Now your task is to sum those weirdly formatted numbers and convert them to the traditional number we use.
The first line of input will contain a number . The next line will contain a number , written in the mentioned 7-less system. The numbers may contain leading zeros.
Print the sum of all the in our traditional number system.
Input | Output |
---|---|
2 19 28 | 42 |
28 in Masud’s representation is 25 in ours, and 19 in his is 17 in ours. Thus, the sum is (25 + 17) = 42. |