#include <iostream>
#include <string>
using namespace std;
int main(){
    string temp;
    cin>>temp;
    string type;
    cin>>type;
    if(type!="Fahrenheit" || type!="Celsius"){
        cout<<"Invalid input";
    }
    else if(type=="Fahrenheit"){
        cout<< (temp*9/5)+32;
    }
    else{
        cout<< (temp-32)*5/9;
    }
    return 0;
}