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

public class Main{
    public static void main(String args[]) throws IOException{
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));


	Stack stack=new Stack(1000);
	
	String str[]=br.readLine().split(" ");

	for(int i=0;i<str.length;i++){
	    if ( str[i].equals("+")){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b+a);
	    } else if ( str[i].equals("-") ){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b-a);
	    } else if ( str[i].equals("*")){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b*a);
	    } else {
		int x = Integer.parseInt(str[i]);
		stack.push(x);
	    }
	}
	System.out.println(stack.pop());
    }
}
class Stack{
    int top;
    final int MAX;
    int S[];
    
    public Stack(int MAX){
	top=0;
	this.MAX=MAX;
	S=new int[MAX];
    }
    public boolean isEmpty(){
	return top==0;
    }

    public boolean isFull(){
	return top>=MAX-1;
    }

    public void push(int x){
	if(!isFull()){
	    top++;
	    S[top]=x;
	}
    }
    public int pop(){
	if(!isEmpty()){
	    top--;
	    return S[top+1];
	}
	return -1;
    }
}
 import java.io.*; io.* java import java.util.*; util.* java public class Main{
    public static void main(String args[]) throws IOException{
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));


	Stack stack=new Stack(1000);
	
	String str[]=br.readLine().split(" ");

	for(int i=0;i<str.length;i++){
	    if ( str[i].equals("+")){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b+a);
	    } else if ( str[i].equals("-") ){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b-a);
	    } else if ( str[i].equals("*")){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b*a);
	    } else {
		int x = Integer.parseInt(str[i]);
		stack.push(x);
	    }
	}
	System.out.println(stack.pop());
    }
} Main public static void main(String args[]) throws IOException{
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));


	Stack stack=new Stack(1000);
	
	String str[]=br.readLine().split(" ");

	for(int i=0;i<str.length;i++){
	    if ( str[i].equals("+")){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b+a);
	    } else if ( str[i].equals("-") ){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b-a);
	    } else if ( str[i].equals("*")){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b*a);
	    } else {
		int x = Integer.parseInt(str[i]);
		stack.push(x);
	    }
	}
	System.out.println(stack.pop());
    } main {
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));


	Stack stack=new Stack(1000);
	
	String str[]=br.readLine().split(" ");

	for(int i=0;i<str.length;i++){
	    if ( str[i].equals("+")){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b+a);
	    } else if ( str[i].equals("-") ){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b-a);
	    } else if ( str[i].equals("*")){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b*a);
	    } else {
		int x = Integer.parseInt(str[i]);
		stack.push(x);
	    }
	}
	System.out.println(stack.pop());
    } BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) Stack stack=new Stack(1000); stack new Stack(1000) String str[]=br.readLine().split(" "); str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " for(int i=0;i<str.length;i++){
	    if ( str[i].equals("+")){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b+a);
	    } else if ( str[i].equals("-") ){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b-a);
	    } else if ( str[i].equals("*")){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b*a);
	    } else {
		int x = Integer.parseInt(str[i]);
		stack.push(x);
	    }
	} int i=0; int i=0; i 0 i<str.length i str.length str str.length i++ i++ i {
	    if ( str[i].equals("+")){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b+a);
	    } else if ( str[i].equals("-") ){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b-a);
	    } else if ( str[i].equals("*")){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b*a);
	    } else {
		int x = Integer.parseInt(str[i]);
		stack.push(x);
	    }
	} {
	    if ( str[i].equals("+")){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b+a);
	    } else if ( str[i].equals("-") ){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b-a);
	    } else if ( str[i].equals("*")){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b*a);
	    } else {
		int x = Integer.parseInt(str[i]);
		stack.push(x);
	    }
	} if ( str[i].equals("+")){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b+a);
	    } else if ( str[i].equals("-") ){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b-a);
	    } else if ( str[i].equals("*")){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b*a);
	    } else {
		int x = Integer.parseInt(str[i]);
		stack.push(x);
	    } str[i].equals("+") str[i].equals str[i] str i "+" {
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b+a);
	    } int a=stack.pop(); a stack.pop() stack.pop stack int b=stack.pop(); b stack.pop() stack.pop stack stack.push(b+a) stack.push stack b+a b a if ( str[i].equals("-") ){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b-a);
	    } else if ( str[i].equals("*")){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b*a);
	    } else {
		int x = Integer.parseInt(str[i]);
		stack.push(x);
	    } str[i].equals("-") str[i].equals str[i] str i "-" {
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b-a);
	    } int a=stack.pop(); a stack.pop() stack.pop stack int b=stack.pop(); b stack.pop() stack.pop stack stack.push(b-a) stack.push stack b-a b a if ( str[i].equals("*")){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b*a);
	    } else {
		int x = Integer.parseInt(str[i]);
		stack.push(x);
	    } str[i].equals("*") str[i].equals str[i] str i "*" {
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b*a);
	    } int a=stack.pop(); a stack.pop() stack.pop stack int b=stack.pop(); b stack.pop() stack.pop stack stack.push(b*a) stack.push stack b*a b a {
		int x = Integer.parseInt(str[i]);
		stack.push(x);
	    } int x = Integer.parseInt(str[i]); x Integer.parseInt(str[i]) Integer.parseInt Integer str[i] str i stack.push(x) stack.push stack x System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack String args[] args class Stack{
    int top;
    final int MAX;
    int S[];
    
    public Stack(int MAX){
	top=0;
	this.MAX=MAX;
	S=new int[MAX];
    }
    public boolean isEmpty(){
	return top==0;
    }

    public boolean isFull(){
	return top>=MAX-1;
    }

    public void push(int x){
	if(!isFull()){
	    top++;
	    S[top]=x;
	}
    }
    public int pop(){
	if(!isEmpty()){
	    top--;
	    return S[top+1];
	}
	return -1;
    }
} Stack int top; top final int MAX; MAX int S[]; S public Stack(int MAX){
	top=0;
	this.MAX=MAX;
	S=new int[MAX];
    } Stack {
	top=0;
	this.MAX=MAX;
	S=new int[MAX];
    } top=0 top 0 this.MAX=MAX this.MAX this this.MAX MAX S=new int[MAX] S new int[MAX] MAX int MAX MAX public boolean isEmpty(){
	return top==0;
    } isEmpty {
	return top==0;
    } return top==0; top==0 top 0 public boolean isFull(){
	return top>=MAX-1;
    } isFull {
	return top>=MAX-1;
    } return top>=MAX-1; top>=MAX-1 top MAX-1 MAX 1 public void push(int x){
	if(!isFull()){
	    top++;
	    S[top]=x;
	}
    } push {
	if(!isFull()){
	    top++;
	    S[top]=x;
	}
    } if(!isFull()){
	    top++;
	    S[top]=x;
	} !isFull() isFull() isFull {
	    top++;
	    S[top]=x;
	} top++ top S[top]=x S[top] S top x int x x public int pop(){
	if(!isEmpty()){
	    top--;
	    return S[top+1];
	}
	return -1;
    } pop {
	if(!isEmpty()){
	    top--;
	    return S[top+1];
	}
	return -1;
    } if(!isEmpty()){
	    top--;
	    return S[top+1];
	} !isEmpty() isEmpty() isEmpty {
	    top--;
	    return S[top+1];
	} top-- top return S[top+1]; S[top+1] S top+1 top 1 return -1; -1 1 public class Main{
    public static void main(String args[]) throws IOException{
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));


	Stack stack=new Stack(1000);
	
	String str[]=br.readLine().split(" ");

	for(int i=0;i<str.length;i++){
	    if ( str[i].equals("+")){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b+a);
	    } else if ( str[i].equals("-") ){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b-a);
	    } else if ( str[i].equals("*")){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b*a);
	    } else {
		int x = Integer.parseInt(str[i]);
		stack.push(x);
	    }
	}
	System.out.println(stack.pop());
    }
} public class Main{
    public static void main(String args[]) throws IOException{
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));


	Stack stack=new Stack(1000);
	
	String str[]=br.readLine().split(" ");

	for(int i=0;i<str.length;i++){
	    if ( str[i].equals("+")){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b+a);
	    } else if ( str[i].equals("-") ){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b-a);
	    } else if ( str[i].equals("*")){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b*a);
	    } else {
		int x = Integer.parseInt(str[i]);
		stack.push(x);
	    }
	}
	System.out.println(stack.pop());
    }
} Main
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String args[]) throws IOException{
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));


	Stack stack=new Stack(1000);
	
	String str[]=br.readLine().split(" ");

	for(int i=0;i<str.length;i++){
	    if ( str[i].equals("+")){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b+a);
	    } else if ( str[i].equals("-") ){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b-a);
	    } else if ( str[i].equals("*")){
		int a=stack.pop();
		int b=stack.pop();
		stack.push(b*a);
	    } else {
		int x = Integer.parseInt(str[i]);
		stack.push(x);
	    }
	}
	System.out.println(stack.pop());
    }
}
class Stack{
    int top;
    final int MAX;
    int S[];
    
    public Stack(int MAX){
	top=0;
	this.MAX=MAX;
	S=new int[MAX];
    }
    public boolean isEmpty(){
	return top==0;
    }

    public boolean isFull(){
	return top>=MAX-1;
    }

    public void push(int x){
	if(!isFull()){
	    top++;
	    S[top]=x;
	}
    }
    public int pop(){
	if(!isEmpty()){
	    top--;
	    return S[top+1];
	}
	return -1;
    }
}

