import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String a="0";
		IntStack iStack=new IntStack();
		while(sc.hasNext()){
			String str=sc.next();
			if(str.equals("+")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(x+y);
				//System.out.println(x+"+"+y);
			}else if(str.equals("-")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(y-x);				
				//System.out.println(x+"-"+y);
			}else if(str.equals("*")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(x*y);
				//System.out.println(x+"*"+y);
			}else{
				int m=0;
				int n=1;
				for(int i=str.length()-1;i>=0;i--){
					m+=n*(str.charAt(i)-a.charAt(0));
					n=10*n;
				}
				iStack.push(m);
			}
		}
		System.out.println(iStack.pop());
	}
}

class IntStack{
	private int[] data=new int[256];
	private int sp=0;
	public int pop(){
		sp--;
		return data[sp];
	}
	public void push(int value){
		data[sp]=value;
		sp++;
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String a="0";
		IntStack iStack=new IntStack();
		while(sc.hasNext()){
			String str=sc.next();
			if(str.equals("+")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(x+y);
				//System.out.println(x+"+"+y);
			}else if(str.equals("-")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(y-x);				
				//System.out.println(x+"-"+y);
			}else if(str.equals("*")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(x*y);
				//System.out.println(x+"*"+y);
			}else{
				int m=0;
				int n=1;
				for(int i=str.length()-1;i>=0;i--){
					m+=n*(str.charAt(i)-a.charAt(0));
					n=10*n;
				}
				iStack.push(m);
			}
		}
		System.out.println(iStack.pop());
	}
} Main public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String a="0";
		IntStack iStack=new IntStack();
		while(sc.hasNext()){
			String str=sc.next();
			if(str.equals("+")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(x+y);
				//System.out.println(x+"+"+y);
			}else if(str.equals("-")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(y-x);				
				//System.out.println(x+"-"+y);
			}else if(str.equals("*")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(x*y);
				//System.out.println(x+"*"+y);
			}else{
				int m=0;
				int n=1;
				for(int i=str.length()-1;i>=0;i--){
					m+=n*(str.charAt(i)-a.charAt(0));
					n=10*n;
				}
				iStack.push(m);
			}
		}
		System.out.println(iStack.pop());
	} main {
		Scanner sc=new Scanner(System.in);
		String a="0";
		IntStack iStack=new IntStack();
		while(sc.hasNext()){
			String str=sc.next();
			if(str.equals("+")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(x+y);
				//System.out.println(x+"+"+y);
			}else if(str.equals("-")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(y-x);				
				//System.out.println(x+"-"+y);
			}else if(str.equals("*")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(x*y);
				//System.out.println(x+"*"+y);
			}else{
				int m=0;
				int n=1;
				for(int i=str.length()-1;i>=0;i--){
					m+=n*(str.charAt(i)-a.charAt(0));
					n=10*n;
				}
				iStack.push(m);
			}
		}
		System.out.println(iStack.pop());
	} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) String a="0"; a "0" IntStack iStack=new IntStack(); iStack new IntStack() while(sc.hasNext()){
			String str=sc.next();
			if(str.equals("+")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(x+y);
				//System.out.println(x+"+"+y);
			}else if(str.equals("-")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(y-x);				
				//System.out.println(x+"-"+y);
			}else if(str.equals("*")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(x*y);
				//System.out.println(x+"*"+y);
			}else{
				int m=0;
				int n=1;
				for(int i=str.length()-1;i>=0;i--){
					m+=n*(str.charAt(i)-a.charAt(0));
					n=10*n;
				}
				iStack.push(m);
			}
		} sc.hasNext() sc.hasNext sc {
			String str=sc.next();
			if(str.equals("+")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(x+y);
				//System.out.println(x+"+"+y);
			}else if(str.equals("-")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(y-x);				
				//System.out.println(x+"-"+y);
			}else if(str.equals("*")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(x*y);
				//System.out.println(x+"*"+y);
			}else{
				int m=0;
				int n=1;
				for(int i=str.length()-1;i>=0;i--){
					m+=n*(str.charAt(i)-a.charAt(0));
					n=10*n;
				}
				iStack.push(m);
			}
		} String str=sc.next(); str sc.next() sc.next sc if(str.equals("+")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(x+y);
				//System.out.println(x+"+"+y);
			}else if(str.equals("-")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(y-x);				
				//System.out.println(x+"-"+y);
			}else if(str.equals("*")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(x*y);
				//System.out.println(x+"*"+y);
			}else{
				int m=0;
				int n=1;
				for(int i=str.length()-1;i>=0;i--){
					m+=n*(str.charAt(i)-a.charAt(0));
					n=10*n;
				}
				iStack.push(m);
			} str.equals("+") str.equals str "+" {
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(x+y);
				//System.out.println(x+"+"+y);
			} int x=iStack.pop(); x iStack.pop() iStack.pop iStack int y=iStack.pop(); y iStack.pop() iStack.pop iStack iStack.push(x+y) iStack.push iStack x+y x y if(str.equals("-")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(y-x);				
				//System.out.println(x+"-"+y);
			}else if(str.equals("*")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(x*y);
				//System.out.println(x+"*"+y);
			}else{
				int m=0;
				int n=1;
				for(int i=str.length()-1;i>=0;i--){
					m+=n*(str.charAt(i)-a.charAt(0));
					n=10*n;
				}
				iStack.push(m);
			} str.equals("-") str.equals str "-" {
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(y-x);				
				//System.out.println(x+"-"+y);
			} int x=iStack.pop(); x iStack.pop() iStack.pop iStack int y=iStack.pop(); y iStack.pop() iStack.pop iStack iStack.push(y-x) iStack.push iStack y-x y x if(str.equals("*")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(x*y);
				//System.out.println(x+"*"+y);
			}else{
				int m=0;
				int n=1;
				for(int i=str.length()-1;i>=0;i--){
					m+=n*(str.charAt(i)-a.charAt(0));
					n=10*n;
				}
				iStack.push(m);
			} str.equals("*") str.equals str "*" {
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(x*y);
				//System.out.println(x+"*"+y);
			} int x=iStack.pop(); x iStack.pop() iStack.pop iStack int y=iStack.pop(); y iStack.pop() iStack.pop iStack iStack.push(x*y) iStack.push iStack x*y x y {
				int m=0;
				int n=1;
				for(int i=str.length()-1;i>=0;i--){
					m+=n*(str.charAt(i)-a.charAt(0));
					n=10*n;
				}
				iStack.push(m);
			} int m=0; m 0 int n=1; n 1 for(int i=str.length()-1;i>=0;i--){
					m+=n*(str.charAt(i)-a.charAt(0));
					n=10*n;
				} int i=str.length()-1; int i=str.length()-1; i str.length()-1 str.length() str.length str 1 i>=0 i 0 i-- i-- i {
					m+=n*(str.charAt(i)-a.charAt(0));
					n=10*n;
				} {
					m+=n*(str.charAt(i)-a.charAt(0));
					n=10*n;
				} m+=n*(str.charAt(i)-a.charAt(0)) m n*(str.charAt(i)-a.charAt(0)) n (str.charAt(i)-a.charAt(0)) str.charAt(i) str.charAt str i a.charAt(0) a.charAt a 0 n=10*n n 10*n 10 n iStack.push(m) iStack.push iStack m System.out.println(iStack.pop()) System.out.println System.out System System.out iStack.pop() iStack.pop iStack String[] args args class IntStack{
	private int[] data=new int[256];
	private int sp=0;
	public int pop(){
		sp--;
		return data[sp];
	}
	public void push(int value){
		data[sp]=value;
		sp++;
	}
} IntStack private int[] data=new int[256]; data new int[256] 256 private int sp=0; sp 0 public int pop(){
		sp--;
		return data[sp];
	} pop {
		sp--;
		return data[sp];
	} sp-- sp return data[sp]; data[sp] data sp public void push(int value){
		data[sp]=value;
		sp++;
	} push {
		data[sp]=value;
		sp++;
	} data[sp]=value data[sp] data sp value sp++ sp int value value public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String a="0";
		IntStack iStack=new IntStack();
		while(sc.hasNext()){
			String str=sc.next();
			if(str.equals("+")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(x+y);
				//System.out.println(x+"+"+y);
			}else if(str.equals("-")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(y-x);				
				//System.out.println(x+"-"+y);
			}else if(str.equals("*")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(x*y);
				//System.out.println(x+"*"+y);
			}else{
				int m=0;
				int n=1;
				for(int i=str.length()-1;i>=0;i--){
					m+=n*(str.charAt(i)-a.charAt(0));
					n=10*n;
				}
				iStack.push(m);
			}
		}
		System.out.println(iStack.pop());
	}
} public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String a="0";
		IntStack iStack=new IntStack();
		while(sc.hasNext()){
			String str=sc.next();
			if(str.equals("+")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(x+y);
				//System.out.println(x+"+"+y);
			}else if(str.equals("-")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(y-x);				
				//System.out.println(x+"-"+y);
			}else if(str.equals("*")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(x*y);
				//System.out.println(x+"*"+y);
			}else{
				int m=0;
				int n=1;
				for(int i=str.length()-1;i>=0;i--){
					m+=n*(str.charAt(i)-a.charAt(0));
					n=10*n;
				}
				iStack.push(m);
			}
		}
		System.out.println(iStack.pop());
	}
} Main
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String a="0";
		IntStack iStack=new IntStack();
		while(sc.hasNext()){
			String str=sc.next();
			if(str.equals("+")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(x+y);
				//System.out.println(x+"+"+y);
			}else if(str.equals("-")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(y-x);				
				//System.out.println(x+"-"+y);
			}else if(str.equals("*")){
				int x=iStack.pop();
				int y=iStack.pop();
				iStack.push(x*y);
				//System.out.println(x+"*"+y);
			}else{
				int m=0;
				int n=1;
				for(int i=str.length()-1;i>=0;i--){
					m+=n*(str.charAt(i)-a.charAt(0));
					n=10*n;
				}
				iStack.push(m);
			}
		}
		System.out.println(iStack.pop());
	}
}

class IntStack{
	private int[] data=new int[256];
	private int sp=0;
	public int pop(){
		sp--;
		return data[sp];
	}
	public void push(int value){
		data[sp]=value;
		sp++;
	}
}