This page is still under construction.

Parts of this page are still being built. What you see may change.

Flat

Interview

Time limit3sMemory limit256 MB

Summary
Given room areas and types, compute total area, total bedroom area, and flat cost using half-weighted balcony area.
Level

Easy2 of 10

Topics
Implementation, Math
Solved
No attempts yet

Problem

You are one of the developers of software for a real estate agency. One of the functions you must implement calculates various statistics for the flats the agency is selling. Each flat consists of rooms of different types: bedroom, bathroom, kitchen, balcony, and others.

The cost of a flat equals the product of its reduced total area and the cost of one square metre. The reduced total area is the total area of all rooms except balconies, plus one half of the total area of the balconies.

You are given the area of each room in the flat and the cost of one square metre. Compute the following values for the flat:

  • the total area of all rooms;
  • the total area of all bedrooms;
  • the cost of the flat.

Input

The first line contains two integers nn (1≤n≤101 \le n \le 10) and cc (1≤c≤1000001 \le c \le 100000) — the number of rooms in the flat and the cost of one square metre, respectively.

Each of the next nn lines contains an integer aia_i (1≤ai≤1001 \le a_i \le 100) and a word tit_i — the area of the ii-th room and its type, respectively. The word tit_i is one of: bedroom, bathroom, kitchen, balcony, other.

Output

Print three lines.

The first line contains one integer — the total area of all rooms of the flat.

The second line contains one integer — the total area of all bedrooms of the flat.

The third line contains the cost of the flat. The cost is always a multiple of one half. If the cost is a whole number, print it as an integer with no decimal point; otherwise print it with exactly one digit after the decimal point (that digit is always 5).

Note

The figure shows the flat from the first sample.

Examples2

  1. Example 1

    Input
    6 75000
    8 other
    3 bathroom
    2 bathroom
    10 kitchen
    16 bedroom
    7 balcony
    
    Expected output
    46
    16
    3187500
    
  2. Example 2

    Input
    2 75123
    10 kitchen
    15 balcony
    
    Expected output
    25
    0
    1314652.5