
import java.util.Scanner;
import java.util.Stack;

public class Main {

	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			Stack<String> stack = new Stack<String>();
			String str = sc.nextLine();
			String[] token = str.split(" ");
			for(String t : token) {
				if( t.equals("+") || t.equals("-") || t.equals("*") ) { 
					int first = Integer.parseInt( stack.pop() );
					int second = Integer.parseInt( stack.pop() );
					if(t.equals("+")) {
						stack.push( Integer.toString(first + second) );
					}
					else if( t.equals("-") ) {
						stack.push( Integer.toString(second - first) );
					}
					else {
						stack.push( Integer.toString(first * second) );
					}
					
				}
				else {
					stack.push(t);
				}
			}
			System.out.println( stack.pop() );

		}
	}
} import java.util.Scanner; Scanner java.util import java.util.Stack; Stack java.util public class Main {

	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			Stack<String> stack = new Stack<String>();
			String str = sc.nextLine();
			String[] token = str.split(" ");
			for(String t : token) {
				if( t.equals("+") || t.equals("-") || t.equals("*") ) { 
					int first = Integer.parseInt( stack.pop() );
					int second = Integer.parseInt( stack.pop() );
					if(t.equals("+")) {
						stack.push( Integer.toString(first + second) );
					}
					else if( t.equals("-") ) {
						stack.push( Integer.toString(second - first) );
					}
					else {
						stack.push( Integer.toString(first * second) );
					}
					
				}
				else {
					stack.push(t);
				}
			}
			System.out.println( stack.pop() );

		}
	}
} Main public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			Stack<String> stack = new Stack<String>();
			String str = sc.nextLine();
			String[] token = str.split(" ");
			for(String t : token) {
				if( t.equals("+") || t.equals("-") || t.equals("*") ) { 
					int first = Integer.parseInt( stack.pop() );
					int second = Integer.parseInt( stack.pop() );
					if(t.equals("+")) {
						stack.push( Integer.toString(first + second) );
					}
					else if( t.equals("-") ) {
						stack.push( Integer.toString(second - first) );
					}
					else {
						stack.push( Integer.toString(first * second) );
					}
					
				}
				else {
					stack.push(t);
				}
			}
			System.out.println( stack.pop() );

		}
	} main {
		try(Scanner sc = new Scanner(System.in)) {
			Stack<String> stack = new Stack<String>();
			String str = sc.nextLine();
			String[] token = str.split(" ");
			for(String t : token) {
				if( t.equals("+") || t.equals("-") || t.equals("*") ) { 
					int first = Integer.parseInt( stack.pop() );
					int second = Integer.parseInt( stack.pop() );
					if(t.equals("+")) {
						stack.push( Integer.toString(first + second) );
					}
					else if( t.equals("-") ) {
						stack.push( Integer.toString(second - first) );
					}
					else {
						stack.push( Integer.toString(first * second) );
					}
					
				}
				else {
					stack.push(t);
				}
			}
			System.out.println( stack.pop() );

		}
	} try(Scanner sc = new Scanner(System.in)) {
			Stack<String> stack = new Stack<String>();
			String str = sc.nextLine();
			String[] token = str.split(" ");
			for(String t : token) {
				if( t.equals("+") || t.equals("-") || t.equals("*") ) { 
					int first = Integer.parseInt( stack.pop() );
					int second = Integer.parseInt( stack.pop() );
					if(t.equals("+")) {
						stack.push( Integer.toString(first + second) );
					}
					else if( t.equals("-") ) {
						stack.push( Integer.toString(second - first) );
					}
					else {
						stack.push( Integer.toString(first * second) );
					}
					
				}
				else {
					stack.push(t);
				}
			}
			System.out.println( stack.pop() );

		} {
			Stack<String> stack = new Stack<String>();
			String str = sc.nextLine();
			String[] token = str.split(" ");
			for(String t : token) {
				if( t.equals("+") || t.equals("-") || t.equals("*") ) { 
					int first = Integer.parseInt( stack.pop() );
					int second = Integer.parseInt( stack.pop() );
					if(t.equals("+")) {
						stack.push( Integer.toString(first + second) );
					}
					else if( t.equals("-") ) {
						stack.push( Integer.toString(second - first) );
					}
					else {
						stack.push( Integer.toString(first * second) );
					}
					
				}
				else {
					stack.push(t);
				}
			}
			System.out.println( stack.pop() );

		} Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) Stack<String> stack = new Stack<String>(); stack new Stack<String>() String str = sc.nextLine(); str sc.nextLine() sc.nextLine sc String[] token = str.split(" "); token str.split(" ") str.split str " " for(String t : token) {
				if( t.equals("+") || t.equals("-") || t.equals("*") ) { 
					int first = Integer.parseInt( stack.pop() );
					int second = Integer.parseInt( stack.pop() );
					if(t.equals("+")) {
						stack.push( Integer.toString(first + second) );
					}
					else if( t.equals("-") ) {
						stack.push( Integer.toString(second - first) );
					}
					else {
						stack.push( Integer.toString(first * second) );
					}
					
				}
				else {
					stack.push(t);
				}
			} String t token {
				if( t.equals("+") || t.equals("-") || t.equals("*") ) { 
					int first = Integer.parseInt( stack.pop() );
					int second = Integer.parseInt( stack.pop() );
					if(t.equals("+")) {
						stack.push( Integer.toString(first + second) );
					}
					else if( t.equals("-") ) {
						stack.push( Integer.toString(second - first) );
					}
					else {
						stack.push( Integer.toString(first * second) );
					}
					
				}
				else {
					stack.push(t);
				}
			} {
				if( t.equals("+") || t.equals("-") || t.equals("*") ) { 
					int first = Integer.parseInt( stack.pop() );
					int second = Integer.parseInt( stack.pop() );
					if(t.equals("+")) {
						stack.push( Integer.toString(first + second) );
					}
					else if( t.equals("-") ) {
						stack.push( Integer.toString(second - first) );
					}
					else {
						stack.push( Integer.toString(first * second) );
					}
					
				}
				else {
					stack.push(t);
				}
			} if( t.equals("+") || t.equals("-") || t.equals("*") ) { 
					int first = Integer.parseInt( stack.pop() );
					int second = Integer.parseInt( stack.pop() );
					if(t.equals("+")) {
						stack.push( Integer.toString(first + second) );
					}
					else if( t.equals("-") ) {
						stack.push( Integer.toString(second - first) );
					}
					else {
						stack.push( Integer.toString(first * second) );
					}
					
				}
				else {
					stack.push(t);
				} t.equals("+") || t.equals("-") || t.equals("*") t.equals("+") || t.equals("-") || t.equals("*") t.equals("+") t.equals t "+" t.equals("-") t.equals t "-" t.equals("*") t.equals t "*" { 
					int first = Integer.parseInt( stack.pop() );
					int second = Integer.parseInt( stack.pop() );
					if(t.equals("+")) {
						stack.push( Integer.toString(first + second) );
					}
					else if( t.equals("-") ) {
						stack.push( Integer.toString(second - first) );
					}
					else {
						stack.push( Integer.toString(first * second) );
					}
					
				} int first = Integer.parseInt( stack.pop() ); first Integer.parseInt( stack.pop() ) Integer.parseInt Integer stack.pop() stack.pop stack int second = Integer.parseInt( stack.pop() ); second Integer.parseInt( stack.pop() ) Integer.parseInt Integer stack.pop() stack.pop stack if(t.equals("+")) {
						stack.push( Integer.toString(first + second) );
					}
					else if( t.equals("-") ) {
						stack.push( Integer.toString(second - first) );
					}
					else {
						stack.push( Integer.toString(first * second) );
					} t.equals("+") t.equals t "+" {
						stack.push( Integer.toString(first + second) );
					} stack.push( Integer.toString(first + second) ) stack.push stack Integer.toString(first + second) Integer.toString Integer first + second first second if( t.equals("-") ) {
						stack.push( Integer.toString(second - first) );
					}
					else {
						stack.push( Integer.toString(first * second) );
					} t.equals("-") t.equals t "-" {
						stack.push( Integer.toString(second - first) );
					} stack.push( Integer.toString(second - first) ) stack.push stack Integer.toString(second - first) Integer.toString Integer second - first second first {
						stack.push( Integer.toString(first * second) );
					} stack.push( Integer.toString(first * second) ) stack.push stack Integer.toString(first * second) Integer.toString Integer first * second first second {
					stack.push(t);
				} stack.push(t) stack.push stack t System.out.println( stack.pop() ) System.out.println System.out System System.out stack.pop() stack.pop stack String[] args args public class Main {

	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			Stack<String> stack = new Stack<String>();
			String str = sc.nextLine();
			String[] token = str.split(" ");
			for(String t : token) {
				if( t.equals("+") || t.equals("-") || t.equals("*") ) { 
					int first = Integer.parseInt( stack.pop() );
					int second = Integer.parseInt( stack.pop() );
					if(t.equals("+")) {
						stack.push( Integer.toString(first + second) );
					}
					else if( t.equals("-") ) {
						stack.push( Integer.toString(second - first) );
					}
					else {
						stack.push( Integer.toString(first * second) );
					}
					
				}
				else {
					stack.push(t);
				}
			}
			System.out.println( stack.pop() );

		}
	}
} public class Main {

	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			Stack<String> stack = new Stack<String>();
			String str = sc.nextLine();
			String[] token = str.split(" ");
			for(String t : token) {
				if( t.equals("+") || t.equals("-") || t.equals("*") ) { 
					int first = Integer.parseInt( stack.pop() );
					int second = Integer.parseInt( stack.pop() );
					if(t.equals("+")) {
						stack.push( Integer.toString(first + second) );
					}
					else if( t.equals("-") ) {
						stack.push( Integer.toString(second - first) );
					}
					else {
						stack.push( Integer.toString(first * second) );
					}
					
				}
				else {
					stack.push(t);
				}
			}
			System.out.println( stack.pop() );

		}
	}
} Main

import java.util.Scanner;
import java.util.Stack;

public class Main {

	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			Stack<String> stack = new Stack<String>();
			String str = sc.nextLine();
			String[] token = str.split(" ");
			for(String t : token) {
				if( t.equals("+") || t.equals("-") || t.equals("*") ) { 
					int first = Integer.parseInt( stack.pop() );
					int second = Integer.parseInt( stack.pop() );
					if(t.equals("+")) {
						stack.push( Integer.toString(first + second) );
					}
					else if( t.equals("-") ) {
						stack.push( Integer.toString(second - first) );
					}
					else {
						stack.push( Integer.toString(first * second) );
					}
					
				}
				else {
					stack.push(t);
				}
			}
			System.out.println( stack.pop() );

		}
	}
}
