#include <iostream>
#include <iomanip>
#include <string>
#include <exception>
using namespace std;
class InvalidInputException : public exception{
    public:
    const char*what() const noexcept override{
        return "Invalid input";
    }
};
int main(){
    double temperature;
    string type;
    cin>>temperature;
    cin>>type;
    try{
        if(temperature<0 || temperature>100){
            throw InvalidInputException();
        }
        cout<<fixed<<setprecision(2);
        if(type == "Celsius"){
            double result = (temperature * 9.0 / 5.0) + 32.0;
            cout<<result;
        }
        else if(type == "Fahrenheit"){
            double result = (temperature - 32.0) * 5.0 / 9.0;
            cout<<result;
        }
        else{
            throw InvalidInputException();
        }
    }
    catch  (InvalidException& e){
        cout<<e.what();
    }
    return 0;
}