import java.io.*;
import java.util.Arrays;
import java.util.*;

class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = (br.readLine()).split(" ");
		Deque<Integer> stack = new ArrayDeque<Integer>();
		for (int i = 0; i<str.length ; i++ ) {
			if (str[i].equals("+")) {
				int	a = stack.pop();
				int	b = stack.pop();
				int	c = a+b;
				stack.push(c);	
			}else if(str[i].equals("-")){
				int	a = stack.pop();
				int	b = stack.pop();
				int	c = b-a;
				stack.push(c);	
			}else if (str[i].equals("*")) {
				int	a = stack.pop();
				int	b = stack.pop();		
				int	c = a*b;
				stack.push(c);	
			}else{
				stack.push(Integer.parseInt(str[i]));
			}
		}
		System.out.println(stack.pop());
	}
} import java.io.*; io.* java import java.util.Arrays; Arrays java.util import java.util.*; util.* java class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = (br.readLine()).split(" ");
		Deque<Integer> stack = new ArrayDeque<Integer>();
		for (int i = 0; i<str.length ; i++ ) {
			if (str[i].equals("+")) {
				int	a = stack.pop();
				int	b = stack.pop();
				int	c = a+b;
				stack.push(c);	
			}else if(str[i].equals("-")){
				int	a = stack.pop();
				int	b = stack.pop();
				int	c = b-a;
				stack.push(c);	
			}else if (str[i].equals("*")) {
				int	a = stack.pop();
				int	b = stack.pop();		
				int	c = a*b;
				stack.push(c);	
			}else{
				stack.push(Integer.parseInt(str[i]));
			}
		}
		System.out.println(stack.pop());
	}
} Main public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = (br.readLine()).split(" ");
		Deque<Integer> stack = new ArrayDeque<Integer>();
		for (int i = 0; i<str.length ; i++ ) {
			if (str[i].equals("+")) {
				int	a = stack.pop();
				int	b = stack.pop();
				int	c = a+b;
				stack.push(c);	
			}else if(str[i].equals("-")){
				int	a = stack.pop();
				int	b = stack.pop();
				int	c = b-a;
				stack.push(c);	
			}else if (str[i].equals("*")) {
				int	a = stack.pop();
				int	b = stack.pop();		
				int	c = a*b;
				stack.push(c);	
			}else{
				stack.push(Integer.parseInt(str[i]));
			}
		}
		System.out.println(stack.pop());
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = (br.readLine()).split(" ");
		Deque<Integer> stack = new ArrayDeque<Integer>();
		for (int i = 0; i<str.length ; i++ ) {
			if (str[i].equals("+")) {
				int	a = stack.pop();
				int	b = stack.pop();
				int	c = a+b;
				stack.push(c);	
			}else if(str[i].equals("-")){
				int	a = stack.pop();
				int	b = stack.pop();
				int	c = b-a;
				stack.push(c);	
			}else if (str[i].equals("*")) {
				int	a = stack.pop();
				int	b = stack.pop();		
				int	c = a*b;
				stack.push(c);	
			}else{
				stack.push(Integer.parseInt(str[i]));
			}
		}
		System.out.println(stack.pop());
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] str = (br.readLine()).split(" "); str (br.readLine()).split(" ") (br.readLine()).split (br.readLine()) br.readLine br " " Deque<Integer> stack = new ArrayDeque<Integer>(); stack new ArrayDeque<Integer>() for (int i = 0; i<str.length ; i++ ) {
			if (str[i].equals("+")) {
				int	a = stack.pop();
				int	b = stack.pop();
				int	c = a+b;
				stack.push(c);	
			}else if(str[i].equals("-")){
				int	a = stack.pop();
				int	b = stack.pop();
				int	c = b-a;
				stack.push(c);	
			}else if (str[i].equals("*")) {
				int	a = stack.pop();
				int	b = stack.pop();		
				int	c = a*b;
				stack.push(c);	
			}else{
				stack.push(Integer.parseInt(str[i]));
			}
		} int i = 0; int i = 0; i 0 i<str.length i str.length str str.length i++ i++ i {
			if (str[i].equals("+")) {
				int	a = stack.pop();
				int	b = stack.pop();
				int	c = a+b;
				stack.push(c);	
			}else if(str[i].equals("-")){
				int	a = stack.pop();
				int	b = stack.pop();
				int	c = b-a;
				stack.push(c);	
			}else if (str[i].equals("*")) {
				int	a = stack.pop();
				int	b = stack.pop();		
				int	c = a*b;
				stack.push(c);	
			}else{
				stack.push(Integer.parseInt(str[i]));
			}
		} {
			if (str[i].equals("+")) {
				int	a = stack.pop();
				int	b = stack.pop();
				int	c = a+b;
				stack.push(c);	
			}else if(str[i].equals("-")){
				int	a = stack.pop();
				int	b = stack.pop();
				int	c = b-a;
				stack.push(c);	
			}else if (str[i].equals("*")) {
				int	a = stack.pop();
				int	b = stack.pop();		
				int	c = a*b;
				stack.push(c);	
			}else{
				stack.push(Integer.parseInt(str[i]));
			}
		} if (str[i].equals("+")) {
				int	a = stack.pop();
				int	b = stack.pop();
				int	c = a+b;
				stack.push(c);	
			}else if(str[i].equals("-")){
				int	a = stack.pop();
				int	b = stack.pop();
				int	c = b-a;
				stack.push(c);	
			}else if (str[i].equals("*")) {
				int	a = stack.pop();
				int	b = stack.pop();		
				int	c = a*b;
				stack.push(c);	
			}else{
				stack.push(Integer.parseInt(str[i]));
			} str[i].equals("+") str[i].equals str[i] str i "+" {
				int	a = stack.pop();
				int	b = stack.pop();
				int	c = a+b;
				stack.push(c);	
			} int	a = stack.pop(); a stack.pop() stack.pop stack int	b = stack.pop(); b stack.pop() stack.pop stack int	c = a+b; c a+b a b stack.push(c) stack.push stack c if(str[i].equals("-")){
				int	a = stack.pop();
				int	b = stack.pop();
				int	c = b-a;
				stack.push(c);	
			}else if (str[i].equals("*")) {
				int	a = stack.pop();
				int	b = stack.pop();		
				int	c = a*b;
				stack.push(c);	
			}else{
				stack.push(Integer.parseInt(str[i]));
			} str[i].equals("-") str[i].equals str[i] str i "-" {
				int	a = stack.pop();
				int	b = stack.pop();
				int	c = b-a;
				stack.push(c);	
			} int	a = stack.pop(); a stack.pop() stack.pop stack int	b = stack.pop(); b stack.pop() stack.pop stack int	c = b-a; c b-a b a stack.push(c) stack.push stack c if (str[i].equals("*")) {
				int	a = stack.pop();
				int	b = stack.pop();		
				int	c = a*b;
				stack.push(c);	
			}else{
				stack.push(Integer.parseInt(str[i]));
			} str[i].equals("*") str[i].equals str[i] str i "*" {
				int	a = stack.pop();
				int	b = stack.pop();		
				int	c = a*b;
				stack.push(c);	
			} int	a = stack.pop(); a stack.pop() stack.pop stack int	b = stack.pop(); b stack.pop() stack.pop stack int	c = a*b; c a*b a b stack.push(c) stack.push stack c {
				stack.push(Integer.parseInt(str[i]));
			} stack.push(Integer.parseInt(str[i])) stack.push stack Integer.parseInt(str[i]) Integer.parseInt Integer str[i] str i System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack String[] args args
import java.io.*;
import java.util.Arrays;
import java.util.*;

class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = (br.readLine()).split(" ");
		Deque<Integer> stack = new ArrayDeque<Integer>();
		for (int i = 0; i<str.length ; i++ ) {
			if (str[i].equals("+")) {
				int	a = stack.pop();
				int	b = stack.pop();
				int	c = a+b;
				stack.push(c);	
			}else if(str[i].equals("-")){
				int	a = stack.pop();
				int	b = stack.pop();
				int	c = b-a;
				stack.push(c);	
			}else if (str[i].equals("*")) {
				int	a = stack.pop();
				int	b = stack.pop();		
				int	c = a*b;
				stack.push(c);	
			}else{
				stack.push(Integer.parseInt(str[i]));
			}
		}
		System.out.println(stack.pop());
	}
}