#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

double tax[10] = {10, 15, 25, 28, 33, 35, 39.6};

int taxlimit[4][7] = {{9075, 36900, 89350, 186350, 405100, 406750, -1}, {18150, 73800, 148850, 226850, 405100, 457600, -1}, {12950, 49400, 127550, 206600, 405100, 432200, -1}, {9075, 36900, 74425, 113425, 202550, 228800, -1}};

const int MAXN = 50;

char c[100];
int main() {
    //freopen("b.in", "r", stdin); //sterge;
    cin.getline(c + 1, MAXN);

    double value; cin >> value;
    int n = strlen(c + 1);

    int type;

    if (c[1] == 'S') {
        if (n == 6) type = 0;
        else type = 1;
    }
    else if (c[1] == 'H') type = 2;
    else if (c[1] == 'M') {
        if (n == 25) type = 3;
        else type = 1;
    }

    int poz = 0;

    while (value > taxlimit[type][poz] && poz != 6) ++poz;

    int a = (value * (tax[poz] / 100.0));

    cout << a;

    return 0;
}