#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
using namespace std;

int main() {
    double temp;
    string type;
    
    cin >> temp;
    cin >> type;
    
    transform(type.begin), type.end(), type.begin(), :: tolower};
    
    try {
        if (temp < 0 || temp > 100) {
            throw 1;
        }
        double result;
        
        if (type == "celsius") {
            result =(temp * 9.0 / 5.0) * 32.0;
        } else if (type == "fahrenheit") {
            result = (temp - 32.0) * 5.0 / 9.0;
        } else {
            throw 1;
        }
        
        cout << fixed << setprecision(2) << result;
    }
    catch (...) {
        cout << "Invalid input";
    }
    return 0;
}