#include<bits/stdc++.h>

using namespace std;

int eval(){
	string s;
	cin>>s; 
	
	if(s=="f"){
		int x=eval();
		return 2*x-3; 
	} 
	 else if (s=="g") {
		int x=eval();
		int y=eval();
		return 2*x+y-7;
	}
	 else if (s=="h") {
		int x=eval();
		int y=eval();
		int z=eval();
		return 3*x-2*y+z;
	} else {
		return stoi(s);
	}
}


int main(){
	cout<<eval()<<"\n";
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: