#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
int main()
{
    string temp;
    string type;
    getline(cin,temp);
    getline(cin,type);
    bool isValidNum = true;
    for(char c : temp){
        if(!isdigit(c) && c !='-'){
            isValidNum = false;
            break;
        }
    }
    if(!isValidNum || temp.empty()){
        cout<<"Invalid temperature"<<endl;
        return 0;
    }
    double tempValue = stod(temp);
    if(tempValue < 0 || tempValue>100){
        cout<<"Invalid temperature"<<endl;
        return 0;
    }
    if(type == "Celsius"){
        double fahrenheit = (tempvalue * 9.0/5.0)+32;
        setprecision(2);
        cout<<fahrenheit<<endl;
    }
    else if(type == "Fahrenheit"){
        double Celsius = (tempValue - 32)*5.0/9.0;
        cout<<fixed<<setprecision(2);
        cout<<celsius<<endl;
    }else{
        cout<<"Invalid temperature type"<<endl;
    }
    return 0;
}