import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
import java.util.StringTokenizer;

public class Main {
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		Stack<Integer> s = new Stack<Integer>();
		
		while(sc.hasNext()) {
			String str = sc.next();
			if(str.equals("+")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a+b);			
			} else if(str.equals("-")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a-b);
			} else if(str.equals("*")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a*b);
			} else {
				s.push(Integer.parseInt(str));
			}
		}
		
		System.out.println(s.pop());

	}

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        boolean hasNext(){
        	if(st != null && st.hasMoreElements()) {
        		return true;
        	} else {
        		try {
					br.mark(1024);
					if(br.readLine() == null) {
						br.reset();
						return false;
					} else {
						br.reset();
						return true;
					}
	        			
				} catch (IOException e) {
					e.printStackTrace();
					return false;
				}
        	}
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Stack; Stack java.util import java.util.StringTokenizer; StringTokenizer java.util public class Main {
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		Stack<Integer> s = new Stack<Integer>();
		
		while(sc.hasNext()) {
			String str = sc.next();
			if(str.equals("+")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a+b);			
			} else if(str.equals("-")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a-b);
			} else if(str.equals("*")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a*b);
			} else {
				s.push(Integer.parseInt(str));
			}
		}
		
		System.out.println(s.pop());

	}

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        boolean hasNext(){
        	if(st != null && st.hasMoreElements()) {
        		return true;
        	} else {
        		try {
					br.mark(1024);
					if(br.readLine() == null) {
						br.reset();
						return false;
					} else {
						br.reset();
						return true;
					}
	        			
				} catch (IOException e) {
					e.printStackTrace();
					return false;
				}
        	}
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
} Main private static FastScanner sc = new FastScanner(); sc new FastScanner() public static void main(String[] args) {
		Stack<Integer> s = new Stack<Integer>();
		
		while(sc.hasNext()) {
			String str = sc.next();
			if(str.equals("+")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a+b);			
			} else if(str.equals("-")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a-b);
			} else if(str.equals("*")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a*b);
			} else {
				s.push(Integer.parseInt(str));
			}
		}
		
		System.out.println(s.pop());

	} main {
		Stack<Integer> s = new Stack<Integer>();
		
		while(sc.hasNext()) {
			String str = sc.next();
			if(str.equals("+")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a+b);			
			} else if(str.equals("-")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a-b);
			} else if(str.equals("*")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a*b);
			} else {
				s.push(Integer.parseInt(str));
			}
		}
		
		System.out.println(s.pop());

	} Stack<Integer> s = new Stack<Integer>(); s new Stack<Integer>() while(sc.hasNext()) {
			String str = sc.next();
			if(str.equals("+")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a+b);			
			} else if(str.equals("-")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a-b);
			} else if(str.equals("*")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a*b);
			} else {
				s.push(Integer.parseInt(str));
			}
		} sc.hasNext() sc.hasNext sc {
			String str = sc.next();
			if(str.equals("+")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a+b);			
			} else if(str.equals("-")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a-b);
			} else if(str.equals("*")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a*b);
			} else {
				s.push(Integer.parseInt(str));
			}
		} String str = sc.next(); str sc.next() sc.next sc if(str.equals("+")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a+b);			
			} else if(str.equals("-")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a-b);
			} else if(str.equals("*")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a*b);
			} else {
				s.push(Integer.parseInt(str));
			} str.equals("+") str.equals str "+" {
				int b = s.pop();
				int a = s.pop();
				s.push(a+b);			
			} int b = s.pop(); b s.pop() s.pop s int a = s.pop(); a s.pop() s.pop s s.push(a+b) s.push s a+b a b if(str.equals("-")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a-b);
			} else if(str.equals("*")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a*b);
			} else {
				s.push(Integer.parseInt(str));
			} str.equals("-") str.equals str "-" {
				int b = s.pop();
				int a = s.pop();
				s.push(a-b);
			} int b = s.pop(); b s.pop() s.pop s int a = s.pop(); a s.pop() s.pop s s.push(a-b) s.push s a-b a b if(str.equals("*")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a*b);
			} else {
				s.push(Integer.parseInt(str));
			} str.equals("*") str.equals str "*" {
				int b = s.pop();
				int a = s.pop();
				s.push(a*b);
			} int b = s.pop(); b s.pop() s.pop s int a = s.pop(); a s.pop() s.pop s s.push(a*b) s.push s a*b a b {
				s.push(Integer.parseInt(str));
			} s.push(Integer.parseInt(str)) s.push s Integer.parseInt(str) Integer.parseInt Integer str System.out.println(s.pop()) System.out.println System.out System System.out s.pop() s.pop s String[] args args static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        boolean hasNext(){
        	if(st != null && st.hasMoreElements()) {
        		return true;
        	} else {
        		try {
					br.mark(1024);
					if(br.readLine() == null) {
						br.reset();
						return false;
					} else {
						br.reset();
						return true;
					}
	        			
				} catch (IOException e) {
					e.printStackTrace();
					return false;
				}
        	}
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    } FastScanner BufferedReader br; br StringTokenizer st; st public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        } FastScanner {
            br = new BufferedReader(new InputStreamReader(System.in));
        } br = new BufferedReader(new InputStreamReader(System.in)) br new BufferedReader(new InputStreamReader(System.in)) boolean hasNext(){
        	if(st != null && st.hasMoreElements()) {
        		return true;
        	} else {
        		try {
					br.mark(1024);
					if(br.readLine() == null) {
						br.reset();
						return false;
					} else {
						br.reset();
						return true;
					}
	        			
				} catch (IOException e) {
					e.printStackTrace();
					return false;
				}
        	}
        } hasNext {
        	if(st != null && st.hasMoreElements()) {
        		return true;
        	} else {
        		try {
					br.mark(1024);
					if(br.readLine() == null) {
						br.reset();
						return false;
					} else {
						br.reset();
						return true;
					}
	        			
				} catch (IOException e) {
					e.printStackTrace();
					return false;
				}
        	}
        } if(st != null && st.hasMoreElements()) {
        		return true;
        	} else {
        		try {
					br.mark(1024);
					if(br.readLine() == null) {
						br.reset();
						return false;
					} else {
						br.reset();
						return true;
					}
	        			
				} catch (IOException e) {
					e.printStackTrace();
					return false;
				}
        	} st != null && st.hasMoreElements() st != null st null st.hasMoreElements() st.hasMoreElements st {
        		return true;
        	} return true; true {
        		try {
					br.mark(1024);
					if(br.readLine() == null) {
						br.reset();
						return false;
					} else {
						br.reset();
						return true;
					}
	        			
				} catch (IOException e) {
					e.printStackTrace();
					return false;
				}
        	} try {
					br.mark(1024);
					if(br.readLine() == null) {
						br.reset();
						return false;
					} else {
						br.reset();
						return true;
					}
	        			
				} catch (IOException e) {
					e.printStackTrace();
					return false;
				} catch (IOException e) {
					e.printStackTrace();
					return false;
				} IOException e {
					e.printStackTrace();
					return false;
				} e.printStackTrace() e.printStackTrace e return false; false {
					br.mark(1024);
					if(br.readLine() == null) {
						br.reset();
						return false;
					} else {
						br.reset();
						return true;
					}
	        			
				} br.mark(1024) br.mark br 1024 if(br.readLine() == null) {
						br.reset();
						return false;
					} else {
						br.reset();
						return true;
					} br.readLine() == null br.readLine() br.readLine br null {
						br.reset();
						return false;
					} br.reset() br.reset br return false; false {
						br.reset();
						return true;
					} br.reset() br.reset br return true; true String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        } next {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        } while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            } st == null || !st.hasMoreElements() st == null st null !st.hasMoreElements() st.hasMoreElements() st.hasMoreElements st {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            } try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                } catch (IOException  e) {
                    e.printStackTrace();
                } IOException  e {
                    e.printStackTrace();
                } e.printStackTrace() e.printStackTrace e {
                    st = new StringTokenizer(br.readLine());
                } st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st int nextInt() {
            return Integer.parseInt(next());
        } nextInt {
            return Integer.parseInt(next());
        } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next long nextLong() {
            return Long.parseLong(next());
        } nextLong {
            return Long.parseLong(next());
        } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next double nextDouble() {
            return Double.parseDouble(next());
        } nextDouble {
            return Double.parseDouble(next());
        } return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        } nextLine {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        } String str = ""; str "" try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } IOException e {
                e.printStackTrace();
            } e.printStackTrace() e.printStackTrace e {
                str = br.readLine();
            } str = br.readLine() str br.readLine() br.readLine br return str; str public class Main {
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		Stack<Integer> s = new Stack<Integer>();
		
		while(sc.hasNext()) {
			String str = sc.next();
			if(str.equals("+")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a+b);			
			} else if(str.equals("-")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a-b);
			} else if(str.equals("*")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a*b);
			} else {
				s.push(Integer.parseInt(str));
			}
		}
		
		System.out.println(s.pop());

	}

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        boolean hasNext(){
        	if(st != null && st.hasMoreElements()) {
        		return true;
        	} else {
        		try {
					br.mark(1024);
					if(br.readLine() == null) {
						br.reset();
						return false;
					} else {
						br.reset();
						return true;
					}
	        			
				} catch (IOException e) {
					e.printStackTrace();
					return false;
				}
        	}
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
} public class Main {
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		Stack<Integer> s = new Stack<Integer>();
		
		while(sc.hasNext()) {
			String str = sc.next();
			if(str.equals("+")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a+b);			
			} else if(str.equals("-")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a-b);
			} else if(str.equals("*")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a*b);
			} else {
				s.push(Integer.parseInt(str));
			}
		}
		
		System.out.println(s.pop());

	}

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        boolean hasNext(){
        	if(st != null && st.hasMoreElements()) {
        		return true;
        	} else {
        		try {
					br.mark(1024);
					if(br.readLine() == null) {
						br.reset();
						return false;
					} else {
						br.reset();
						return true;
					}
	        			
				} catch (IOException e) {
					e.printStackTrace();
					return false;
				}
        	}
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
import java.util.StringTokenizer;

public class Main {
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		Stack<Integer> s = new Stack<Integer>();
		
		while(sc.hasNext()) {
			String str = sc.next();
			if(str.equals("+")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a+b);			
			} else if(str.equals("-")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a-b);
			} else if(str.equals("*")) {
				int b = s.pop();
				int a = s.pop();
				s.push(a*b);
			} else {
				s.push(Integer.parseInt(str));
			}
		}
		
		System.out.println(s.pop());

	}

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        boolean hasNext(){
        	if(st != null && st.hasMoreElements()) {
        		return true;
        	} else {
        		try {
					br.mark(1024);
					if(br.readLine() == null) {
						br.reset();
						return false;
					} else {
						br.reset();
						return true;
					}
	        			
				} catch (IOException e) {
					e.printStackTrace();
					return false;
				}
        	}
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}