import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;


class Main {
	//計算用array
	static int[] array = new int[101];
	static int[] temporary = new int[102];
	//ただ読み込むのみ
	static String[] read = new String[300];
	//計算用arrayのindex
	static int count = 0;
	
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
			String string = br.readLine();
			StringTokenizer tokenizer = new StringTokenizer(string," ");
			//一度すべて読み込んでしまう
			int i = 0;
			while (tokenizer.hasMoreTokens()) {
				read[i] = tokenizer.nextToken();
				i++;
			}
			
			int j =0;
			while(read[j]!=null){
				
				String next = read[j];
				if(next.equals("+")){
					popcalc(0);
				}else if(next.equals("-")){
					popcalc(1);
				}else if (next.equals("*")) {
					popcalc(2);
				}else{
					int number = Integer.parseInt(next);
					push(number);
				}
			
				j++;
			}
			
		System.out.println(array[0]);
	}

	
	//popメソッド
	public static void popcalc(int judge) {
	//上から2個とる、1つずつずらす、計算結果をpushする。
		int answer;
		int first = array[0];
		int second = array[1];
		
		//先に計算
		if(judge == 0){
			//足し算
			//System.out.println("たしざん");
			answer=first+second;
		}else if (judge == 1) {
			//引き算
			answer=second-first;
		}else{
			answer=first*second;
		}
		//コピー
		for(int i=0;i<array.length-1;i++){
			temporary[i] = array[i];
		}
		for(int i=2;i<array.length;i++){
			array[i-1]=temporary[i];
		}
		array[0]=answer;
	}
	
	
	//pushメソッド
	public static void push(int number){
		//numberを0番目に、それぞれ一個ずつずらしていく
		
		//同じ配列を複製
		for(int i=0;i<array.length-1;i++){
			temporary[i] = array[i];
		}
		for(int i =0;i<array.length-1;i++){
			array[i+1] = temporary[i];
		}
		array[0]=number;
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.*; util.* java class Main {
	//計算用array
	static int[] array = new int[101];
	static int[] temporary = new int[102];
	//ただ読み込むのみ
	static String[] read = new String[300];
	//計算用arrayのindex
	static int count = 0;
	
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
			String string = br.readLine();
			StringTokenizer tokenizer = new StringTokenizer(string," ");
			//一度すべて読み込んでしまう
			int i = 0;
			while (tokenizer.hasMoreTokens()) {
				read[i] = tokenizer.nextToken();
				i++;
			}
			
			int j =0;
			while(read[j]!=null){
				
				String next = read[j];
				if(next.equals("+")){
					popcalc(0);
				}else if(next.equals("-")){
					popcalc(1);
				}else if (next.equals("*")) {
					popcalc(2);
				}else{
					int number = Integer.parseInt(next);
					push(number);
				}
			
				j++;
			}
			
		System.out.println(array[0]);
	}

	
	//popメソッド
	public static void popcalc(int judge) {
	//上から2個とる、1つずつずらす、計算結果をpushする。
		int answer;
		int first = array[0];
		int second = array[1];
		
		//先に計算
		if(judge == 0){
			//足し算
			//System.out.println("たしざん");
			answer=first+second;
		}else if (judge == 1) {
			//引き算
			answer=second-first;
		}else{
			answer=first*second;
		}
		//コピー
		for(int i=0;i<array.length-1;i++){
			temporary[i] = array[i];
		}
		for(int i=2;i<array.length;i++){
			array[i-1]=temporary[i];
		}
		array[0]=answer;
	}
	
	
	//pushメソッド
	public static void push(int number){
		//numberを0番目に、それぞれ一個ずつずらしていく
		
		//同じ配列を複製
		for(int i=0;i<array.length-1;i++){
			temporary[i] = array[i];
		}
		for(int i =0;i<array.length-1;i++){
			array[i+1] = temporary[i];
		}
		array[0]=number;
	}
} Main //計算用array
	static int[] array = new int[101]; array new int[101] 101 static int[] temporary = new int[102]; temporary new int[102] 102 //ただ読み込むのみ
	static String[] read = new String[300]; read new String[300] 300 //計算用arrayのindex
	static int count = 0; count 0 public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
			String string = br.readLine();
			StringTokenizer tokenizer = new StringTokenizer(string," ");
			//一度すべて読み込んでしまう
			int i = 0;
			while (tokenizer.hasMoreTokens()) {
				read[i] = tokenizer.nextToken();
				i++;
			}
			
			int j =0;
			while(read[j]!=null){
				
				String next = read[j];
				if(next.equals("+")){
					popcalc(0);
				}else if(next.equals("-")){
					popcalc(1);
				}else if (next.equals("*")) {
					popcalc(2);
				}else{
					int number = Integer.parseInt(next);
					push(number);
				}
			
				j++;
			}
			
		System.out.println(array[0]);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
			String string = br.readLine();
			StringTokenizer tokenizer = new StringTokenizer(string," ");
			//一度すべて読み込んでしまう
			int i = 0;
			while (tokenizer.hasMoreTokens()) {
				read[i] = tokenizer.nextToken();
				i++;
			}
			
			int j =0;
			while(read[j]!=null){
				
				String next = read[j];
				if(next.equals("+")){
					popcalc(0);
				}else if(next.equals("-")){
					popcalc(1);
				}else if (next.equals("*")) {
					popcalc(2);
				}else{
					int number = Integer.parseInt(next);
					push(number);
				}
			
				j++;
			}
			
		System.out.println(array[0]);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String string = br.readLine(); string br.readLine() br.readLine br StringTokenizer tokenizer = new StringTokenizer(string," "); tokenizer new StringTokenizer(string," ") int i = 0; i 0 while (tokenizer.hasMoreTokens()) {
				read[i] = tokenizer.nextToken();
				i++;
			} tokenizer.hasMoreTokens() tokenizer.hasMoreTokens tokenizer {
				read[i] = tokenizer.nextToken();
				i++;
			} read[i] = tokenizer.nextToken() read[i] read i tokenizer.nextToken() tokenizer.nextToken tokenizer i++ i int j =0; j 0 while(read[j]!=null){
				
				String next = read[j];
				if(next.equals("+")){
					popcalc(0);
				}else if(next.equals("-")){
					popcalc(1);
				}else if (next.equals("*")) {
					popcalc(2);
				}else{
					int number = Integer.parseInt(next);
					push(number);
				}
			
				j++;
			} read[j]!=null read[j] read j null {
				
				String next = read[j];
				if(next.equals("+")){
					popcalc(0);
				}else if(next.equals("-")){
					popcalc(1);
				}else if (next.equals("*")) {
					popcalc(2);
				}else{
					int number = Integer.parseInt(next);
					push(number);
				}
			
				j++;
			} String next = read[j]; next read[j] read j if(next.equals("+")){
					popcalc(0);
				}else if(next.equals("-")){
					popcalc(1);
				}else if (next.equals("*")) {
					popcalc(2);
				}else{
					int number = Integer.parseInt(next);
					push(number);
				} next.equals("+") next.equals next "+" {
					popcalc(0);
				} popcalc(0) popcalc 0 if(next.equals("-")){
					popcalc(1);
				}else if (next.equals("*")) {
					popcalc(2);
				}else{
					int number = Integer.parseInt(next);
					push(number);
				} next.equals("-") next.equals next "-" {
					popcalc(1);
				} popcalc(1) popcalc 1 if (next.equals("*")) {
					popcalc(2);
				}else{
					int number = Integer.parseInt(next);
					push(number);
				} next.equals("*") next.equals next "*" {
					popcalc(2);
				} popcalc(2) popcalc 2 {
					int number = Integer.parseInt(next);
					push(number);
				} int number = Integer.parseInt(next); number Integer.parseInt(next) Integer.parseInt Integer next push(number) push number j++ j System.out.println(array[0]) System.out.println System.out System System.out array[0] array 0 String[] args args //popメソッド
	public static void popcalc(int judge) {
	//上から2個とる、1つずつずらす、計算結果をpushする。
		int answer;
		int first = array[0];
		int second = array[1];
		
		//先に計算
		if(judge == 0){
			//足し算
			//System.out.println("たしざん");
			answer=first+second;
		}else if (judge == 1) {
			//引き算
			answer=second-first;
		}else{
			answer=first*second;
		}
		//コピー
		for(int i=0;i<array.length-1;i++){
			temporary[i] = array[i];
		}
		for(int i=2;i<array.length;i++){
			array[i-1]=temporary[i];
		}
		array[0]=answer;
	} popcalc {
	//上から2個とる、1つずつずらす、計算結果をpushする。
		int answer;
		int first = array[0];
		int second = array[1];
		
		//先に計算
		if(judge == 0){
			//足し算
			//System.out.println("たしざん");
			answer=first+second;
		}else if (judge == 1) {
			//引き算
			answer=second-first;
		}else{
			answer=first*second;
		}
		//コピー
		for(int i=0;i<array.length-1;i++){
			temporary[i] = array[i];
		}
		for(int i=2;i<array.length;i++){
			array[i-1]=temporary[i];
		}
		array[0]=answer;
	} int answer; answer int first = array[0]; first array[0] array 0 int second = array[1]; second array[1] array 1 if(judge == 0){
			//足し算
			//System.out.println("たしざん");
			answer=first+second;
		}else if (judge == 1) {
			//引き算
			answer=second-first;
		}else{
			answer=first*second;
		} judge == 0 judge 0 {
			//足し算
			//System.out.println("たしざん");
			answer=first+second;
		} answer=first+second answer first+second first second if (judge == 1) {
			//引き算
			answer=second-first;
		}else{
			answer=first*second;
		} judge == 1 judge 1 {
			//引き算
			answer=second-first;
		} answer=second-first answer second-first second first {
			answer=first*second;
		} answer=first*second answer first*second first second for(int i=0;i<array.length-1;i++){
			temporary[i] = array[i];
		} int i=0; int i=0; i 0 i<array.length-1 i array.length-1 array.length array array.length 1 i++ i++ i {
			temporary[i] = array[i];
		} {
			temporary[i] = array[i];
		} temporary[i] = array[i] temporary[i] temporary i array[i] array i for(int i=2;i<array.length;i++){
			array[i-1]=temporary[i];
		} int i=2; int i=2; i 2 i<array.length i array.length array array.length i++ i++ i {
			array[i-1]=temporary[i];
		} {
			array[i-1]=temporary[i];
		} array[i-1]=temporary[i] array[i-1] array i-1 i 1 temporary[i] temporary i array[0]=answer array[0] array 0 answer int judge judge //pushメソッド
	public static void push(int number){
		//numberを0番目に、それぞれ一個ずつずらしていく
		
		//同じ配列を複製
		for(int i=0;i<array.length-1;i++){
			temporary[i] = array[i];
		}
		for(int i =0;i<array.length-1;i++){
			array[i+1] = temporary[i];
		}
		array[0]=number;
	} push {
		//numberを0番目に、それぞれ一個ずつずらしていく
		
		//同じ配列を複製
		for(int i=0;i<array.length-1;i++){
			temporary[i] = array[i];
		}
		for(int i =0;i<array.length-1;i++){
			array[i+1] = temporary[i];
		}
		array[0]=number;
	} for(int i=0;i<array.length-1;i++){
			temporary[i] = array[i];
		} int i=0; int i=0; i 0 i<array.length-1 i array.length-1 array.length array array.length 1 i++ i++ i {
			temporary[i] = array[i];
		} {
			temporary[i] = array[i];
		} temporary[i] = array[i] temporary[i] temporary i array[i] array i for(int i =0;i<array.length-1;i++){
			array[i+1] = temporary[i];
		} int i =0; int i =0; i 0 i<array.length-1 i array.length-1 array.length array array.length 1 i++ i++ i {
			array[i+1] = temporary[i];
		} {
			array[i+1] = temporary[i];
		} array[i+1] = temporary[i] array[i+1] array i+1 i 1 temporary[i] temporary i array[0]=number array[0] array 0 number int number number
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;


class Main {
	//計算用array
	static int[] array = new int[101];
	static int[] temporary = new int[102];
	//ただ読み込むのみ
	static String[] read = new String[300];
	//計算用arrayのindex
	static int count = 0;
	
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
			String string = br.readLine();
			StringTokenizer tokenizer = new StringTokenizer(string," ");
			//一度すべて読み込んでしまう
			int i = 0;
			while (tokenizer.hasMoreTokens()) {
				read[i] = tokenizer.nextToken();
				i++;
			}
			
			int j =0;
			while(read[j]!=null){
				
				String next = read[j];
				if(next.equals("+")){
					popcalc(0);
				}else if(next.equals("-")){
					popcalc(1);
				}else if (next.equals("*")) {
					popcalc(2);
				}else{
					int number = Integer.parseInt(next);
					push(number);
				}
			
				j++;
			}
			
		System.out.println(array[0]);
	}

	
	//popメソッド
	public static void popcalc(int judge) {
	//上から2個とる、1つずつずらす、計算結果をpushする。
		int answer;
		int first = array[0];
		int second = array[1];
		
		//先に計算
		if(judge == 0){
			//足し算
			//System.out.println("たしざん");
			answer=first+second;
		}else if (judge == 1) {
			//引き算
			answer=second-first;
		}else{
			answer=first*second;
		}
		//コピー
		for(int i=0;i<array.length-1;i++){
			temporary[i] = array[i];
		}
		for(int i=2;i<array.length;i++){
			array[i-1]=temporary[i];
		}
		array[0]=answer;
	}
	
	
	//pushメソッド
	public static void push(int number){
		//numberを0番目に、それぞれ一個ずつずらしていく
		
		//同じ配列を複製
		for(int i=0;i<array.length-1;i++){
			temporary[i] = array[i];
		}
		for(int i =0;i<array.length-1;i++){
			array[i+1] = temporary[i];
		}
		array[0]=number;
	}
}