
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc= new Scanner(System.in);
		
		String S[] = sc.nextLine().split(" ");
		int stack[] = new int[S.length];
		int idx = 0, a, b;  

		for(int i=0; i<S.length; i++){			
			try{
				int x = Integer.parseInt(S[i]);
				stack[idx++] = x;

			}catch(java.lang.NumberFormatException ex){
				b = stack[--idx];
				a = stack[--idx];

				switch (S[i]) {
					case "+":	stack[idx++] = a + b; break;
					case "-":	stack[idx++] = a - b; break;
					case "*":	stack[idx++] = a * b; break;
				}
			}
		}
		System.out.println(stack[--idx]);
	}	
} import java.util.*; util.* java class Main{
	public static void main(String[] args){
		Scanner sc= new Scanner(System.in);
		
		String S[] = sc.nextLine().split(" ");
		int stack[] = new int[S.length];
		int idx = 0, a, b;  

		for(int i=0; i<S.length; i++){			
			try{
				int x = Integer.parseInt(S[i]);
				stack[idx++] = x;

			}catch(java.lang.NumberFormatException ex){
				b = stack[--idx];
				a = stack[--idx];

				switch (S[i]) {
					case "+":	stack[idx++] = a + b; break;
					case "-":	stack[idx++] = a - b; break;
					case "*":	stack[idx++] = a * b; break;
				}
			}
		}
		System.out.println(stack[--idx]);
	}	
} Main public static void main(String[] args){
		Scanner sc= new Scanner(System.in);
		
		String S[] = sc.nextLine().split(" ");
		int stack[] = new int[S.length];
		int idx = 0, a, b;  

		for(int i=0; i<S.length; i++){			
			try{
				int x = Integer.parseInt(S[i]);
				stack[idx++] = x;

			}catch(java.lang.NumberFormatException ex){
				b = stack[--idx];
				a = stack[--idx];

				switch (S[i]) {
					case "+":	stack[idx++] = a + b; break;
					case "-":	stack[idx++] = a - b; break;
					case "*":	stack[idx++] = a * b; break;
				}
			}
		}
		System.out.println(stack[--idx]);
	} main {
		Scanner sc= new Scanner(System.in);
		
		String S[] = sc.nextLine().split(" ");
		int stack[] = new int[S.length];
		int idx = 0, a, b;  

		for(int i=0; i<S.length; i++){			
			try{
				int x = Integer.parseInt(S[i]);
				stack[idx++] = x;

			}catch(java.lang.NumberFormatException ex){
				b = stack[--idx];
				a = stack[--idx];

				switch (S[i]) {
					case "+":	stack[idx++] = a + b; break;
					case "-":	stack[idx++] = a - b; break;
					case "*":	stack[idx++] = a * b; break;
				}
			}
		}
		System.out.println(stack[--idx]);
	} Scanner sc= new Scanner(System.in); sc new Scanner(System.in) String S[] = sc.nextLine().split(" "); S sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " int stack[] = new int[S.length]; stack new int[S.length] S.length S S.length int idx = 0 idx 0 a a b; b for(int i=0; i<S.length; i++){			
			try{
				int x = Integer.parseInt(S[i]);
				stack[idx++] = x;

			}catch(java.lang.NumberFormatException ex){
				b = stack[--idx];
				a = stack[--idx];

				switch (S[i]) {
					case "+":	stack[idx++] = a + b; break;
					case "-":	stack[idx++] = a - b; break;
					case "*":	stack[idx++] = a * b; break;
				}
			}
		} int i=0; int i=0; i 0 i<S.length i S.length S S.length i++ i++ i {			
			try{
				int x = Integer.parseInt(S[i]);
				stack[idx++] = x;

			}catch(java.lang.NumberFormatException ex){
				b = stack[--idx];
				a = stack[--idx];

				switch (S[i]) {
					case "+":	stack[idx++] = a + b; break;
					case "-":	stack[idx++] = a - b; break;
					case "*":	stack[idx++] = a * b; break;
				}
			}
		} {			
			try{
				int x = Integer.parseInt(S[i]);
				stack[idx++] = x;

			}catch(java.lang.NumberFormatException ex){
				b = stack[--idx];
				a = stack[--idx];

				switch (S[i]) {
					case "+":	stack[idx++] = a + b; break;
					case "-":	stack[idx++] = a - b; break;
					case "*":	stack[idx++] = a * b; break;
				}
			}
		} try{
				int x = Integer.parseInt(S[i]);
				stack[idx++] = x;

			}catch(java.lang.NumberFormatException ex){
				b = stack[--idx];
				a = stack[--idx];

				switch (S[i]) {
					case "+":	stack[idx++] = a + b; break;
					case "-":	stack[idx++] = a - b; break;
					case "*":	stack[idx++] = a * b; break;
				}
			} catch(java.lang.NumberFormatException ex){
				b = stack[--idx];
				a = stack[--idx];

				switch (S[i]) {
					case "+":	stack[idx++] = a + b; break;
					case "-":	stack[idx++] = a - b; break;
					case "*":	stack[idx++] = a * b; break;
				}
			} java.lang.NumberFormatException ex {
				b = stack[--idx];
				a = stack[--idx];

				switch (S[i]) {
					case "+":	stack[idx++] = a + b; break;
					case "-":	stack[idx++] = a - b; break;
					case "*":	stack[idx++] = a * b; break;
				}
			} b = stack[--idx] b stack[--idx] stack --idx idx a = stack[--idx] a stack[--idx] stack --idx idx switch (S[i]) {
					case "+":	stack[idx++] = a + b; break;
					case "-":	stack[idx++] = a - b; break;
					case "*":	stack[idx++] = a * b; break;
				} S[i] S i case "+": "+" case "+": stack[idx++] = a + b stack[idx++] stack idx++ idx a + b a b break; case "-": "-" case "-": stack[idx++] = a - b stack[idx++] stack idx++ idx a - b a b break; case "*": "*" case "*": stack[idx++] = a * b stack[idx++] stack idx++ idx a * b a b break; {
				int x = Integer.parseInt(S[i]);
				stack[idx++] = x;

			} int x = Integer.parseInt(S[i]); x Integer.parseInt(S[i]) Integer.parseInt Integer S[i] S i stack[idx++] = x stack[idx++] stack idx++ idx x System.out.println(stack[--idx]) System.out.println System.out System System.out stack[--idx] stack --idx idx String[] args args

import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc= new Scanner(System.in);
		
		String S[] = sc.nextLine().split(" ");
		int stack[] = new int[S.length];
		int idx = 0, a, b;  

		for(int i=0; i<S.length; i++){			
			try{
				int x = Integer.parseInt(S[i]);
				stack[idx++] = x;

			}catch(java.lang.NumberFormatException ex){
				b = stack[--idx];
				a = stack[--idx];

				switch (S[i]) {
					case "+":	stack[idx++] = a + b; break;
					case "-":	stack[idx++] = a - b; break;
					case "*":	stack[idx++] = a * b; break;
				}
			}
		}
		System.out.println(stack[--idx]);
	}	
}