eolymp
bolt
Try our new interface for solving problems
Problems

Diamond

Diamond

You are a big fancier of jewelry and gemstones. Recently, a remarkable diamond was put for sale in the jewelry store next to your house. Unfortunately, its price was also remarkable - \textbf{X} dollars. Regretful, you had to state that this is way too much. Apparently, other potential buyers also came to the same conclusion, because soon the store started an advertising campaign. "Get a \textbf{5}\% discount on the diamond for each letter of your name!," read the streamer by the frontdoor. The formulation left some ambiguities, so you decided to question the sellers. As it turned out: \begin{itemize} \item If a letter occurs in the name several times, it's only counted once. For example, "\textbf{alexandra}" contains only \textbf{7} letters in terms of the campaign. \item \textbf{5}\% discount is multiplied by the number of distinct letters in the name. I.e., "\textbf{alexandra}" would get a \textbf{35}\% discount. \item The discounts exceeding \textbf{100}\% are not provided, but a \textbf{100}\% discount is okay (yep, the sellers questioned your sanity when they heard this inquiry). \end{itemize} Of course, not making use of such a generous oer would be a crime, but maybe you can save more? By chance, you know a person who makes fake passports. His service is paid as follows: A fake passport costs \textbf{A} dollars. It may contain your real name without changes, or the name may be altered using any number of operations of the following three kinds. \begin{itemize} \item Inserting a letter at any position in the name costs \textbf{B} dollars. \item Erasing a letter at any position in the name costs \textbf{C} dollars. If a name contains a single letter, erasing it is not allowed. \item Replacing a letter at some position with any other letter of the English alphabet costs \textbf{D} dollars. \end{itemize} Given \textbf{X}, \textbf{A}, \textbf{B}, \textbf{C}, \textbf{D} and your real \textbf{name}, determine the least amount of money which you need to obtain the diamond (count both the money spent on buying the diamond and the money spent on the fake passport, if any). Taking a fake passport is not neccessary  you may just provide your real passport at the store. \InputFile The first line of input contains integer \textbf{X}. The second line contains integers \textbf{A}, \textbf{B}, \textbf{C} and \textbf{D} (\textbf{1} ≤ \textbf{X}, \textbf{A}, \textbf{B}, \textbf{C}, \textbf{D} ≤ \textbf{1000000}), separated by single spaces. The third line contains \textbf{Name}. It contains from \textbf{1} to \textbf{15} characters and consists of lowercase English letters only. \OutputFile Print the least amount of money you need to get the diamond, measured in cents (a dollar is \textbf{100} cents).
Time limit 1 second
Memory limit 64 MiB
Input example #1
100
1 2 3 4
eldar
Output example #1
3100
Author Ivan Metelsky
Source Winter School, Kharkov, 2011, Day 7