A task we encounter every day is data compression. Sending large files takes a lot of time and we would like to do it as fast as we can. For really big files it is faster to first compress
them, then send them, and finally to decompress on the receiver's computer than just to send the file. Here we face such a problem. We have a text file and three rules supported by the decompression routine, and we would like to design a compatible compressor. The shorter the resulting file is, the better the compression procedure. The decompression rules are as follows:
- when reading a letter 'a'-'z', print this letter,
- when reading the symbol '+', look at the number n following it and print again the last n letters,
- when reading the symbol '-', look at the number n following it and erase the last n letters.
One line with text to compress.
One line with compressed text.
Score is sum of all letters of all texts after compression.