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

public class Main{
	public static void main(String args[]) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		operateStack ost = new operateStack();
		String[] str;
		int len, top = 0;
		long op, cal;
		
		str = br.readLine().split(" ", 0);
		len = str.length;
		
		for(int i = 0; i < len; i++){
			
			if(str[i].equals("+")){
				ost.calc(1);
			}
			else if(str[i].equals("-")){
				ost.calc(2);
			}
			else if(str[i].equals("*")){
				ost.calc(3);
			}
			else{
				op = Long.parseLong(str[i]);
				ost.push(op);
			}
		}
		
		System.out.println(ost.pop());
	}
}

class operateStack{
	long[] stack = new long[100];
	int top;
	
	operateStack(){
		for(int i = 0; i < 100; i++){
			stack[i] = 0;
		}
		top = 0;
	}
	
	void push(long op){
		if(top == 0 && stack[top] == 0){
			stack[top] = op;
		}
		else{
			top ++;
			stack[top] = op;
		}
	}
	
	long pop(){
		long op = stack[top];
		stack[top] = 0;
		
		if(top > 0){
			top --;
		}
		return op;
	}
	
	void calc(int flag){
		long op, op2;
		long cal;
		
		op = pop();
		op2 = pop();
		
		switch(flag){
		case 1:
			cal = op2 + op;
			break;
		case 2:
			cal = op2 - op;
			break;
		default:
			cal = op2 * op;
			break;
		}
		
		push(cal);
	}
} import java.util.*; util.* java import java.io.*; io.* java public class Main{
	public static void main(String args[]) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		operateStack ost = new operateStack();
		String[] str;
		int len, top = 0;
		long op, cal;
		
		str = br.readLine().split(" ", 0);
		len = str.length;
		
		for(int i = 0; i < len; i++){
			
			if(str[i].equals("+")){
				ost.calc(1);
			}
			else if(str[i].equals("-")){
				ost.calc(2);
			}
			else if(str[i].equals("*")){
				ost.calc(3);
			}
			else{
				op = Long.parseLong(str[i]);
				ost.push(op);
			}
		}
		
		System.out.println(ost.pop());
	}
} Main public static void main(String args[]) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		operateStack ost = new operateStack();
		String[] str;
		int len, top = 0;
		long op, cal;
		
		str = br.readLine().split(" ", 0);
		len = str.length;
		
		for(int i = 0; i < len; i++){
			
			if(str[i].equals("+")){
				ost.calc(1);
			}
			else if(str[i].equals("-")){
				ost.calc(2);
			}
			else if(str[i].equals("*")){
				ost.calc(3);
			}
			else{
				op = Long.parseLong(str[i]);
				ost.push(op);
			}
		}
		
		System.out.println(ost.pop());
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		operateStack ost = new operateStack();
		String[] str;
		int len, top = 0;
		long op, cal;
		
		str = br.readLine().split(" ", 0);
		len = str.length;
		
		for(int i = 0; i < len; i++){
			
			if(str[i].equals("+")){
				ost.calc(1);
			}
			else if(str[i].equals("-")){
				ost.calc(2);
			}
			else if(str[i].equals("*")){
				ost.calc(3);
			}
			else{
				op = Long.parseLong(str[i]);
				ost.push(op);
			}
		}
		
		System.out.println(ost.pop());
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) operateStack ost = new operateStack(); ost new operateStack() String[] str; str int len len top = 0; top 0 long op op cal; cal str = br.readLine().split(" ", 0) str br.readLine().split(" ", 0) br.readLine().split br.readLine() br.readLine br " " 0 len = str.length len str.length str str.length for(int i = 0; i < len; i++){
			
			if(str[i].equals("+")){
				ost.calc(1);
			}
			else if(str[i].equals("-")){
				ost.calc(2);
			}
			else if(str[i].equals("*")){
				ost.calc(3);
			}
			else{
				op = Long.parseLong(str[i]);
				ost.push(op);
			}
		} int i = 0; int i = 0; i 0 i < len i len i++ i++ i {
			
			if(str[i].equals("+")){
				ost.calc(1);
			}
			else if(str[i].equals("-")){
				ost.calc(2);
			}
			else if(str[i].equals("*")){
				ost.calc(3);
			}
			else{
				op = Long.parseLong(str[i]);
				ost.push(op);
			}
		} {
			
			if(str[i].equals("+")){
				ost.calc(1);
			}
			else if(str[i].equals("-")){
				ost.calc(2);
			}
			else if(str[i].equals("*")){
				ost.calc(3);
			}
			else{
				op = Long.parseLong(str[i]);
				ost.push(op);
			}
		} if(str[i].equals("+")){
				ost.calc(1);
			}
			else if(str[i].equals("-")){
				ost.calc(2);
			}
			else if(str[i].equals("*")){
				ost.calc(3);
			}
			else{
				op = Long.parseLong(str[i]);
				ost.push(op);
			} str[i].equals("+") str[i].equals str[i] str i "+" {
				ost.calc(1);
			} ost.calc(1) ost.calc ost 1 if(str[i].equals("-")){
				ost.calc(2);
			}
			else if(str[i].equals("*")){
				ost.calc(3);
			}
			else{
				op = Long.parseLong(str[i]);
				ost.push(op);
			} str[i].equals("-") str[i].equals str[i] str i "-" {
				ost.calc(2);
			} ost.calc(2) ost.calc ost 2 if(str[i].equals("*")){
				ost.calc(3);
			}
			else{
				op = Long.parseLong(str[i]);
				ost.push(op);
			} str[i].equals("*") str[i].equals str[i] str i "*" {
				ost.calc(3);
			} ost.calc(3) ost.calc ost 3 {
				op = Long.parseLong(str[i]);
				ost.push(op);
			} op = Long.parseLong(str[i]) op Long.parseLong(str[i]) Long.parseLong Long str[i] str i ost.push(op) ost.push ost op System.out.println(ost.pop()) System.out.println System.out System System.out ost.pop() ost.pop ost String args[] args class operateStack{
	long[] stack = new long[100];
	int top;
	
	operateStack(){
		for(int i = 0; i < 100; i++){
			stack[i] = 0;
		}
		top = 0;
	}
	
	void push(long op){
		if(top == 0 && stack[top] == 0){
			stack[top] = op;
		}
		else{
			top ++;
			stack[top] = op;
		}
	}
	
	long pop(){
		long op = stack[top];
		stack[top] = 0;
		
		if(top > 0){
			top --;
		}
		return op;
	}
	
	void calc(int flag){
		long op, op2;
		long cal;
		
		op = pop();
		op2 = pop();
		
		switch(flag){
		case 1:
			cal = op2 + op;
			break;
		case 2:
			cal = op2 - op;
			break;
		default:
			cal = op2 * op;
			break;
		}
		
		push(cal);
	}
} operateStack long[] stack = new long[100]; stack new long[100] 100 int top; top operateStack(){
		for(int i = 0; i < 100; i++){
			stack[i] = 0;
		}
		top = 0;
	} operateStack {
		for(int i = 0; i < 100; i++){
			stack[i] = 0;
		}
		top = 0;
	} for(int i = 0; i < 100; i++){
			stack[i] = 0;
		} int i = 0; int i = 0; i 0 i < 100 i 100 i++ i++ i {
			stack[i] = 0;
		} {
			stack[i] = 0;
		} stack[i] = 0 stack[i] stack i 0 top = 0 top 0 void push(long op){
		if(top == 0 && stack[top] == 0){
			stack[top] = op;
		}
		else{
			top ++;
			stack[top] = op;
		}
	} push {
		if(top == 0 && stack[top] == 0){
			stack[top] = op;
		}
		else{
			top ++;
			stack[top] = op;
		}
	} if(top == 0 && stack[top] == 0){
			stack[top] = op;
		}
		else{
			top ++;
			stack[top] = op;
		} top == 0 && stack[top] == 0 top == 0 top 0 stack[top] == 0 stack[top] stack top 0 {
			stack[top] = op;
		} stack[top] = op stack[top] stack top op {
			top ++;
			stack[top] = op;
		} top ++ top stack[top] = op stack[top] stack top op long op op long pop(){
		long op = stack[top];
		stack[top] = 0;
		
		if(top > 0){
			top --;
		}
		return op;
	} pop {
		long op = stack[top];
		stack[top] = 0;
		
		if(top > 0){
			top --;
		}
		return op;
	} long op = stack[top]; op stack[top] stack top stack[top] = 0 stack[top] stack top 0 if(top > 0){
			top --;
		} top > 0 top 0 {
			top --;
		} top -- top return op; op void calc(int flag){
		long op, op2;
		long cal;
		
		op = pop();
		op2 = pop();
		
		switch(flag){
		case 1:
			cal = op2 + op;
			break;
		case 2:
			cal = op2 - op;
			break;
		default:
			cal = op2 * op;
			break;
		}
		
		push(cal);
	} calc {
		long op, op2;
		long cal;
		
		op = pop();
		op2 = pop();
		
		switch(flag){
		case 1:
			cal = op2 + op;
			break;
		case 2:
			cal = op2 - op;
			break;
		default:
			cal = op2 * op;
			break;
		}
		
		push(cal);
	} long op op op2; op2 long cal; cal op = pop() op pop() pop op2 = pop() op2 pop() pop switch(flag){
		case 1:
			cal = op2 + op;
			break;
		case 2:
			cal = op2 - op;
			break;
		default:
			cal = op2 * op;
			break;
		} flag case 1: 1 case 1: cal = op2 + op cal op2 + op op2 op break; case 2: 2 case 2: cal = op2 - op cal op2 - op op2 op break; default: default: cal = op2 * op cal op2 * op op2 op break; push(cal) push cal int flag flag public class Main{
	public static void main(String args[]) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		operateStack ost = new operateStack();
		String[] str;
		int len, top = 0;
		long op, cal;
		
		str = br.readLine().split(" ", 0);
		len = str.length;
		
		for(int i = 0; i < len; i++){
			
			if(str[i].equals("+")){
				ost.calc(1);
			}
			else if(str[i].equals("-")){
				ost.calc(2);
			}
			else if(str[i].equals("*")){
				ost.calc(3);
			}
			else{
				op = Long.parseLong(str[i]);
				ost.push(op);
			}
		}
		
		System.out.println(ost.pop());
	}
} public class Main{
	public static void main(String args[]) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		operateStack ost = new operateStack();
		String[] str;
		int len, top = 0;
		long op, cal;
		
		str = br.readLine().split(" ", 0);
		len = str.length;
		
		for(int i = 0; i < len; i++){
			
			if(str[i].equals("+")){
				ost.calc(1);
			}
			else if(str[i].equals("-")){
				ost.calc(2);
			}
			else if(str[i].equals("*")){
				ost.calc(3);
			}
			else{
				op = Long.parseLong(str[i]);
				ost.push(op);
			}
		}
		
		System.out.println(ost.pop());
	}
} Main
import java.util.*;
import java.io.*;

public class Main{
	public static void main(String args[]) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		operateStack ost = new operateStack();
		String[] str;
		int len, top = 0;
		long op, cal;
		
		str = br.readLine().split(" ", 0);
		len = str.length;
		
		for(int i = 0; i < len; i++){
			
			if(str[i].equals("+")){
				ost.calc(1);
			}
			else if(str[i].equals("-")){
				ost.calc(2);
			}
			else if(str[i].equals("*")){
				ost.calc(3);
			}
			else{
				op = Long.parseLong(str[i]);
				ost.push(op);
			}
		}
		
		System.out.println(ost.pop());
	}
}

class operateStack{
	long[] stack = new long[100];
	int top;
	
	operateStack(){
		for(int i = 0; i < 100; i++){
			stack[i] = 0;
		}
		top = 0;
	}
	
	void push(long op){
		if(top == 0 && stack[top] == 0){
			stack[top] = op;
		}
		else{
			top ++;
			stack[top] = op;
		}
	}
	
	long pop(){
		long op = stack[top];
		stack[top] = 0;
		
		if(top > 0){
			top --;
		}
		return op;
	}
	
	void calc(int flag){
		long op, op2;
		long cal;
		
		op = pop();
		op2 = pop();
		
		switch(flag){
		case 1:
			cal = op2 + op;
			break;
		case 2:
			cal = op2 - op;
			break;
		default:
			cal = op2 * op;
			break;
		}
		
		push(cal);
	}
}