import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
	public static void main(String[] args) throws IOException {

		//Scanner scan = new Scanner(System.in);

		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);

		String inputData = br.readLine();
		String data[] = inputData.split(" ");
		Deque<String> deque = new ArrayDeque<>();

		Pattern p = Pattern.compile("^[0-9]*$");
		for (int i = 0; i < data.length ; i++) {
			Matcher m = p.matcher(data[i]);
			if(m.find()) {
				deque.push(data[i]);
			}else {
				String b = deque.pop();
				String a = deque.pop();
				String r = "";
				switch(data[i]){
				case "+":
					r = String.valueOf(Integer.parseInt(a) + Integer.parseInt(b));
					break;
				case "-":
					r = String.valueOf(Integer.parseInt(a) - Integer.parseInt(b));
					break;
				case "*":
					r = String.valueOf(Integer.parseInt(a) * Integer.parseInt(b));
					break;
				}
				deque.push(r);
			}
		}
		System.out.println(deque.pop());
	}

}
 import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayDeque; ArrayDeque java.util import java.util.Deque; Deque java.util import java.util.regex.Matcher; Matcher java.util.regex import java.util.regex.Pattern; Pattern java.util.regex public class Main {
	public static void main(String[] args) throws IOException {

		//Scanner scan = new Scanner(System.in);

		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);

		String inputData = br.readLine();
		String data[] = inputData.split(" ");
		Deque<String> deque = new ArrayDeque<>();

		Pattern p = Pattern.compile("^[0-9]*$");
		for (int i = 0; i < data.length ; i++) {
			Matcher m = p.matcher(data[i]);
			if(m.find()) {
				deque.push(data[i]);
			}else {
				String b = deque.pop();
				String a = deque.pop();
				String r = "";
				switch(data[i]){
				case "+":
					r = String.valueOf(Integer.parseInt(a) + Integer.parseInt(b));
					break;
				case "-":
					r = String.valueOf(Integer.parseInt(a) - Integer.parseInt(b));
					break;
				case "*":
					r = String.valueOf(Integer.parseInt(a) * Integer.parseInt(b));
					break;
				}
				deque.push(r);
			}
		}
		System.out.println(deque.pop());
	}

} Main public static void main(String[] args) throws IOException {

		//Scanner scan = new Scanner(System.in);

		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);

		String inputData = br.readLine();
		String data[] = inputData.split(" ");
		Deque<String> deque = new ArrayDeque<>();

		Pattern p = Pattern.compile("^[0-9]*$");
		for (int i = 0; i < data.length ; i++) {
			Matcher m = p.matcher(data[i]);
			if(m.find()) {
				deque.push(data[i]);
			}else {
				String b = deque.pop();
				String a = deque.pop();
				String r = "";
				switch(data[i]){
				case "+":
					r = String.valueOf(Integer.parseInt(a) + Integer.parseInt(b));
					break;
				case "-":
					r = String.valueOf(Integer.parseInt(a) - Integer.parseInt(b));
					break;
				case "*":
					r = String.valueOf(Integer.parseInt(a) * Integer.parseInt(b));
					break;
				}
				deque.push(r);
			}
		}
		System.out.println(deque.pop());
	} main {

		//Scanner scan = new Scanner(System.in);

		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);

		String inputData = br.readLine();
		String data[] = inputData.split(" ");
		Deque<String> deque = new ArrayDeque<>();

		Pattern p = Pattern.compile("^[0-9]*$");
		for (int i = 0; i < data.length ; i++) {
			Matcher m = p.matcher(data[i]);
			if(m.find()) {
				deque.push(data[i]);
			}else {
				String b = deque.pop();
				String a = deque.pop();
				String r = "";
				switch(data[i]){
				case "+":
					r = String.valueOf(Integer.parseInt(a) + Integer.parseInt(b));
					break;
				case "-":
					r = String.valueOf(Integer.parseInt(a) - Integer.parseInt(b));
					break;
				case "*":
					r = String.valueOf(Integer.parseInt(a) * Integer.parseInt(b));
					break;
				}
				deque.push(r);
			}
		}
		System.out.println(deque.pop());
	} InputStreamReader isr = new InputStreamReader(System.in); isr new InputStreamReader(System.in) BufferedReader br = new BufferedReader(isr); br new BufferedReader(isr) String inputData = br.readLine(); inputData br.readLine() br.readLine br String data[] = inputData.split(" "); data inputData.split(" ") inputData.split inputData " " Deque<String> deque = new ArrayDeque<>(); deque new ArrayDeque<>() Pattern p = Pattern.compile("^[0-9]*$"); p Pattern.compile("^[0-9]*$") Pattern.compile Pattern "^[0-9]*$" for (int i = 0; i < data.length ; i++) {
			Matcher m = p.matcher(data[i]);
			if(m.find()) {
				deque.push(data[i]);
			}else {
				String b = deque.pop();
				String a = deque.pop();
				String r = "";
				switch(data[i]){
				case "+":
					r = String.valueOf(Integer.parseInt(a) + Integer.parseInt(b));
					break;
				case "-":
					r = String.valueOf(Integer.parseInt(a) - Integer.parseInt(b));
					break;
				case "*":
					r = String.valueOf(Integer.parseInt(a) * Integer.parseInt(b));
					break;
				}
				deque.push(r);
			}
		} int i = 0; int i = 0; i 0 i < data.length i data.length data data.length i++ i++ i {
			Matcher m = p.matcher(data[i]);
			if(m.find()) {
				deque.push(data[i]);
			}else {
				String b = deque.pop();
				String a = deque.pop();
				String r = "";
				switch(data[i]){
				case "+":
					r = String.valueOf(Integer.parseInt(a) + Integer.parseInt(b));
					break;
				case "-":
					r = String.valueOf(Integer.parseInt(a) - Integer.parseInt(b));
					break;
				case "*":
					r = String.valueOf(Integer.parseInt(a) * Integer.parseInt(b));
					break;
				}
				deque.push(r);
			}
		} {
			Matcher m = p.matcher(data[i]);
			if(m.find()) {
				deque.push(data[i]);
			}else {
				String b = deque.pop();
				String a = deque.pop();
				String r = "";
				switch(data[i]){
				case "+":
					r = String.valueOf(Integer.parseInt(a) + Integer.parseInt(b));
					break;
				case "-":
					r = String.valueOf(Integer.parseInt(a) - Integer.parseInt(b));
					break;
				case "*":
					r = String.valueOf(Integer.parseInt(a) * Integer.parseInt(b));
					break;
				}
				deque.push(r);
			}
		} Matcher m = p.matcher(data[i]); m p.matcher(data[i]) p.matcher p data[i] data i if(m.find()) {
				deque.push(data[i]);
			}else {
				String b = deque.pop();
				String a = deque.pop();
				String r = "";
				switch(data[i]){
				case "+":
					r = String.valueOf(Integer.parseInt(a) + Integer.parseInt(b));
					break;
				case "-":
					r = String.valueOf(Integer.parseInt(a) - Integer.parseInt(b));
					break;
				case "*":
					r = String.valueOf(Integer.parseInt(a) * Integer.parseInt(b));
					break;
				}
				deque.push(r);
			} m.find() m.find m {
				deque.push(data[i]);
			} deque.push(data[i]) deque.push deque data[i] data i {
				String b = deque.pop();
				String a = deque.pop();
				String r = "";
				switch(data[i]){
				case "+":
					r = String.valueOf(Integer.parseInt(a) + Integer.parseInt(b));
					break;
				case "-":
					r = String.valueOf(Integer.parseInt(a) - Integer.parseInt(b));
					break;
				case "*":
					r = String.valueOf(Integer.parseInt(a) * Integer.parseInt(b));
					break;
				}
				deque.push(r);
			} String b = deque.pop(); b deque.pop() deque.pop deque String a = deque.pop(); a deque.pop() deque.pop deque String r = ""; r "" switch(data[i]){
				case "+":
					r = String.valueOf(Integer.parseInt(a) + Integer.parseInt(b));
					break;
				case "-":
					r = String.valueOf(Integer.parseInt(a) - Integer.parseInt(b));
					break;
				case "*":
					r = String.valueOf(Integer.parseInt(a) * Integer.parseInt(b));
					break;
				} data[i] data i case "+": "+" case "+": r = String.valueOf(Integer.parseInt(a) + Integer.parseInt(b)) r String.valueOf(Integer.parseInt(a) + Integer.parseInt(b)) String.valueOf String Integer.parseInt(a) + Integer.parseInt(b) Integer.parseInt(a) Integer.parseInt Integer a Integer.parseInt(b) Integer.parseInt Integer b break; case "-": "-" case "-": r = String.valueOf(Integer.parseInt(a) - Integer.parseInt(b)) r String.valueOf(Integer.parseInt(a) - Integer.parseInt(b)) String.valueOf String Integer.parseInt(a) - Integer.parseInt(b) Integer.parseInt(a) Integer.parseInt Integer a Integer.parseInt(b) Integer.parseInt Integer b break; case "*": "*" case "*": r = String.valueOf(Integer.parseInt(a) * Integer.parseInt(b)) r String.valueOf(Integer.parseInt(a) * Integer.parseInt(b)) String.valueOf String Integer.parseInt(a) * Integer.parseInt(b) Integer.parseInt(a) Integer.parseInt Integer a Integer.parseInt(b) Integer.parseInt Integer b break; deque.push(r) deque.push deque r System.out.println(deque.pop()) System.out.println System.out System System.out deque.pop() deque.pop deque String[] args args public class Main {
	public static void main(String[] args) throws IOException {

		//Scanner scan = new Scanner(System.in);

		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);

		String inputData = br.readLine();
		String data[] = inputData.split(" ");
		Deque<String> deque = new ArrayDeque<>();

		Pattern p = Pattern.compile("^[0-9]*$");
		for (int i = 0; i < data.length ; i++) {
			Matcher m = p.matcher(data[i]);
			if(m.find()) {
				deque.push(data[i]);
			}else {
				String b = deque.pop();
				String a = deque.pop();
				String r = "";
				switch(data[i]){
				case "+":
					r = String.valueOf(Integer.parseInt(a) + Integer.parseInt(b));
					break;
				case "-":
					r = String.valueOf(Integer.parseInt(a) - Integer.parseInt(b));
					break;
				case "*":
					r = String.valueOf(Integer.parseInt(a) * Integer.parseInt(b));
					break;
				}
				deque.push(r);
			}
		}
		System.out.println(deque.pop());
	}

} public class Main {
	public static void main(String[] args) throws IOException {

		//Scanner scan = new Scanner(System.in);

		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);

		String inputData = br.readLine();
		String data[] = inputData.split(" ");
		Deque<String> deque = new ArrayDeque<>();

		Pattern p = Pattern.compile("^[0-9]*$");
		for (int i = 0; i < data.length ; i++) {
			Matcher m = p.matcher(data[i]);
			if(m.find()) {
				deque.push(data[i]);
			}else {
				String b = deque.pop();
				String a = deque.pop();
				String r = "";
				switch(data[i]){
				case "+":
					r = String.valueOf(Integer.parseInt(a) + Integer.parseInt(b));
					break;
				case "-":
					r = String.valueOf(Integer.parseInt(a) - Integer.parseInt(b));
					break;
				case "*":
					r = String.valueOf(Integer.parseInt(a) * Integer.parseInt(b));
					break;
				}
				deque.push(r);
			}
		}
		System.out.println(deque.pop());
	}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
	public static void main(String[] args) throws IOException {

		//Scanner scan = new Scanner(System.in);

		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);

		String inputData = br.readLine();
		String data[] = inputData.split(" ");
		Deque<String> deque = new ArrayDeque<>();

		Pattern p = Pattern.compile("^[0-9]*$");
		for (int i = 0; i < data.length ; i++) {
			Matcher m = p.matcher(data[i]);
			if(m.find()) {
				deque.push(data[i]);
			}else {
				String b = deque.pop();
				String a = deque.pop();
				String r = "";
				switch(data[i]){
				case "+":
					r = String.valueOf(Integer.parseInt(a) + Integer.parseInt(b));
					break;
				case "-":
					r = String.valueOf(Integer.parseInt(a) - Integer.parseInt(b));
					break;
				case "*":
					r = String.valueOf(Integer.parseInt(a) * Integer.parseInt(b));
					break;
				}
				deque.push(r);
			}
		}
		System.out.println(deque.pop());
	}

}

