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

Задача 38155. Final cost - 1


Задача

Темы: Строки
Imagine that you have been hired in the IT department of a chain grocery store. Starting next month, it is planned to introduce a 20% discount on some products. You are required to write a program for calculating the final cost of the purchase, taking into account all discounts.

A purchase is specified as a list of products, where each product is described in the format <ItemName> <price> x<quantity>. If the name of the product ends with the substring «sale», then the price of the product at the final calculation of the purchase is reduced by 20%, rounded down to the nearest whole number. So, for example, if the price of the goods was 12 rubles, taking into account the discount, it will be 9 rubles. The discount does not apply to other products.

The total cost of each product is calculated using the formula finalPrice⋅x, where finalPrice is the final price, possibly including discounts and rounding, and x is the quantity of the product in the shopping list. 
Your task is to calculate the total cost of the purchase.

Input
The first line contains the number n - the number of items in the purchase (1≤n≤1000).
The next n lines contain descriptions of the items in the purchase in the format: <ItemName> <price> x<number>.
The product name consists of no more than 20 lowercase Latin letters. Price - a natural number that is strictly greater than 1, but not more than 1000. Quantity - a natural number not greater than 100.

Imprint
Print one number - the total cost of the purchase.
 
Examples
# Input Output Explanation
1 5
bananassale 10x2
breadfixed 5 x5
colafixed 20x2
gumsale 9x10
tea 2x15
181 In the test from the example, the total cost of goods will be: 8, 5, 20, 7 and 2, respectively. Total purchase price: 8⋅2+5⋅5+20⋅2+7⋅10+2⋅15=181.