#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main() {
unsigned int n, ai, S=0, Ss=0, Sb=0;
float Ck, c;
string ti;
cin >> n >> c;
for(int i=1; i<=n; i++){
cin >> ai >> ti;
S += ai;
if (ti == "bedroom"){
Ss += ai;
}
else if (ti == "balcony"){
Sb += ai;
}
}
Ck = (S - Sb/2.) * c;
cout << S << "\n"
<< Ss << "\n"
<< fixed << setprecision(6) << Ck << "\n";
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8aW9tYW5pcD4KI2luY2x1ZGUgPHN0cmluZz4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkgewoJdW5zaWduZWQgaW50IG4sIGFpLCBTPTAsIFNzPTAsIFNiPTA7CglmbG9hdCBDaywgYzsKCXN0cmluZyB0aTsKCWNpbiA+PiBuID4+IGM7Cglmb3IoaW50IGk9MTsgaTw9bjsgaSsrKXsKCQljaW4gPj4gYWkgPj4gdGk7CgkgICAgUyArPSBhaTsKCQlpZiAodGkgPT0gImJlZHJvb20iKXsKCQkJU3MgKz0gYWk7IAoJCX0KCQllbHNlIGlmICh0aSA9PSAiYmFsY29ueSIpewoJCQlTYiArPSBhaTsgCgkJfQoJfQoJQ2sgPSAoUyAtIFNiLzIuKSAqIGM7Cgljb3V0IDw8IFMgPDwgIlxuIiAKCSAgICAgPDwgU3MgPDwgIlxuIiAKCSAgICAgPDwgZml4ZWQgPDwgc2V0cHJlY2lzaW9uKDYpIDw8IENrIDw8ICJcbiI7IAoJcmV0dXJuIDA7Cn0=