import java.util.*;
 
public class Main {
	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		Stack<Integer> stk = new Stack<Integer>();
		String s;
		while(sc.hasNext()){
			s = sc.next();
			if(s.equals("+")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n1+n2);
			}
			else if(s.equals("-")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n2-n1);
			}
			else if(s.equals("*")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n1 * n2);
			}
			else{
				stk.push(Integer.valueOf(s));
			}
		}
		cout(stk.pop());
	}
	
	
	
	public static boolean isPrime(int n){
		for(int i=2;i<=n*n;i++){
			if(n%i==0) return true;
		}
		return false;
	}
	public static int gcd(int a,int b){
		if(a%b==0) return b;
		else return gcd(b,a%b);
	}
	public static void showary(int[] ary){
		for(int i=0;i<ary.length-1;i++){
			System.out.print(ary[i]+" ");
		}
		cout(ary[ary.length-1]);
	}
	public static void cout(String n){
		System.out.println(n);
	}
	
	public static void cout(int n){
		System.out.println(n);
	}
	public static void cout(boolean n){
		if(n==true){
			cout("true");
		}else{
			cout("false");
		}
	}
} import java.util.*; util.* java public class Main {
	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		Stack<Integer> stk = new Stack<Integer>();
		String s;
		while(sc.hasNext()){
			s = sc.next();
			if(s.equals("+")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n1+n2);
			}
			else if(s.equals("-")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n2-n1);
			}
			else if(s.equals("*")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n1 * n2);
			}
			else{
				stk.push(Integer.valueOf(s));
			}
		}
		cout(stk.pop());
	}
	
	
	
	public static boolean isPrime(int n){
		for(int i=2;i<=n*n;i++){
			if(n%i==0) return true;
		}
		return false;
	}
	public static int gcd(int a,int b){
		if(a%b==0) return b;
		else return gcd(b,a%b);
	}
	public static void showary(int[] ary){
		for(int i=0;i<ary.length-1;i++){
			System.out.print(ary[i]+" ");
		}
		cout(ary[ary.length-1]);
	}
	public static void cout(String n){
		System.out.println(n);
	}
	
	public static void cout(int n){
		System.out.println(n);
	}
	public static void cout(boolean n){
		if(n==true){
			cout("true");
		}else{
			cout("false");
		}
	}
} Main static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args) {
		Stack<Integer> stk = new Stack<Integer>();
		String s;
		while(sc.hasNext()){
			s = sc.next();
			if(s.equals("+")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n1+n2);
			}
			else if(s.equals("-")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n2-n1);
			}
			else if(s.equals("*")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n1 * n2);
			}
			else{
				stk.push(Integer.valueOf(s));
			}
		}
		cout(stk.pop());
	} main {
		Stack<Integer> stk = new Stack<Integer>();
		String s;
		while(sc.hasNext()){
			s = sc.next();
			if(s.equals("+")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n1+n2);
			}
			else if(s.equals("-")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n2-n1);
			}
			else if(s.equals("*")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n1 * n2);
			}
			else{
				stk.push(Integer.valueOf(s));
			}
		}
		cout(stk.pop());
	} Stack<Integer> stk = new Stack<Integer>(); stk new Stack<Integer>() String s; s while(sc.hasNext()){
			s = sc.next();
			if(s.equals("+")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n1+n2);
			}
			else if(s.equals("-")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n2-n1);
			}
			else if(s.equals("*")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n1 * n2);
			}
			else{
				stk.push(Integer.valueOf(s));
			}
		} sc.hasNext() sc.hasNext sc {
			s = sc.next();
			if(s.equals("+")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n1+n2);
			}
			else if(s.equals("-")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n2-n1);
			}
			else if(s.equals("*")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n1 * n2);
			}
			else{
				stk.push(Integer.valueOf(s));
			}
		} s = sc.next() s sc.next() sc.next sc if(s.equals("+")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n1+n2);
			}
			else if(s.equals("-")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n2-n1);
			}
			else if(s.equals("*")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n1 * n2);
			}
			else{
				stk.push(Integer.valueOf(s));
			} s.equals("+") s.equals s "+" {
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n1+n2);
			} int n1 = stk.pop(); n1 stk.pop() stk.pop stk int n2 = stk.pop(); n2 stk.pop() stk.pop stk stk.push(n1+n2) stk.push stk n1+n2 n1 n2 if(s.equals("-")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n2-n1);
			}
			else if(s.equals("*")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n1 * n2);
			}
			else{
				stk.push(Integer.valueOf(s));
			} s.equals("-") s.equals s "-" {
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n2-n1);
			} int n1 = stk.pop(); n1 stk.pop() stk.pop stk int n2 = stk.pop(); n2 stk.pop() stk.pop stk stk.push(n2-n1) stk.push stk n2-n1 n2 n1 if(s.equals("*")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n1 * n2);
			}
			else{
				stk.push(Integer.valueOf(s));
			} s.equals("*") s.equals s "*" {
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n1 * n2);
			} int n1 = stk.pop(); n1 stk.pop() stk.pop stk int n2 = stk.pop(); n2 stk.pop() stk.pop stk stk.push(n1 * n2) stk.push stk n1 * n2 n1 n2 {
				stk.push(Integer.valueOf(s));
			} stk.push(Integer.valueOf(s)) stk.push stk Integer.valueOf(s) Integer.valueOf Integer s cout(stk.pop()) cout stk.pop() stk.pop stk String[] args args public static boolean isPrime(int n){
		for(int i=2;i<=n*n;i++){
			if(n%i==0) return true;
		}
		return false;
	} isPrime {
		for(int i=2;i<=n*n;i++){
			if(n%i==0) return true;
		}
		return false;
	} for(int i=2;i<=n*n;i++){
			if(n%i==0) return true;
		} int i=2; int i=2; i 2 i<=n*n i n*n n n i++ i++ i {
			if(n%i==0) return true;
		} {
			if(n%i==0) return true;
		} if(n%i==0) return true; n%i==0 n%i n i 0 return true; true return false; false int n n public static int gcd(int a,int b){
		if(a%b==0) return b;
		else return gcd(b,a%b);
	} gcd {
		if(a%b==0) return b;
		else return gcd(b,a%b);
	} if(a%b==0) return b;
		else return gcd(b,a%b); a%b==0 a%b a b 0 return b; b return gcd(b,a%b); gcd(b,a%b) gcd b a%b a b int a a int b b public static void showary(int[] ary){
		for(int i=0;i<ary.length-1;i++){
			System.out.print(ary[i]+" ");
		}
		cout(ary[ary.length-1]);
	} showary {
		for(int i=0;i<ary.length-1;i++){
			System.out.print(ary[i]+" ");
		}
		cout(ary[ary.length-1]);
	} for(int i=0;i<ary.length-1;i++){
			System.out.print(ary[i]+" ");
		} int i=0; int i=0; i 0 i<ary.length-1 i ary.length-1 ary.length ary ary.length 1 i++ i++ i {
			System.out.print(ary[i]+" ");
		} {
			System.out.print(ary[i]+" ");
		} System.out.print(ary[i]+" ") System.out.print System.out System System.out ary[i]+" " ary[i] ary i " " cout(ary[ary.length-1]) cout ary[ary.length-1] ary ary.length-1 ary.length ary ary.length 1 int[] ary ary public static void cout(String n){
		System.out.println(n);
	} cout {
		System.out.println(n);
	} System.out.println(n) System.out.println System.out System System.out n String n n public static void cout(int n){
		System.out.println(n);
	} cout {
		System.out.println(n);
	} System.out.println(n) System.out.println System.out System System.out n int n n public static void cout(boolean n){
		if(n==true){
			cout("true");
		}else{
			cout("false");
		}
	} cout {
		if(n==true){
			cout("true");
		}else{
			cout("false");
		}
	} if(n==true){
			cout("true");
		}else{
			cout("false");
		} n==true n true {
			cout("true");
		} cout("true") cout "true" {
			cout("false");
		} cout("false") cout "false" boolean n n public class Main {
	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		Stack<Integer> stk = new Stack<Integer>();
		String s;
		while(sc.hasNext()){
			s = sc.next();
			if(s.equals("+")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n1+n2);
			}
			else if(s.equals("-")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n2-n1);
			}
			else if(s.equals("*")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n1 * n2);
			}
			else{
				stk.push(Integer.valueOf(s));
			}
		}
		cout(stk.pop());
	}
	
	
	
	public static boolean isPrime(int n){
		for(int i=2;i<=n*n;i++){
			if(n%i==0) return true;
		}
		return false;
	}
	public static int gcd(int a,int b){
		if(a%b==0) return b;
		else return gcd(b,a%b);
	}
	public static void showary(int[] ary){
		for(int i=0;i<ary.length-1;i++){
			System.out.print(ary[i]+" ");
		}
		cout(ary[ary.length-1]);
	}
	public static void cout(String n){
		System.out.println(n);
	}
	
	public static void cout(int n){
		System.out.println(n);
	}
	public static void cout(boolean n){
		if(n==true){
			cout("true");
		}else{
			cout("false");
		}
	}
} public class Main {
	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		Stack<Integer> stk = new Stack<Integer>();
		String s;
		while(sc.hasNext()){
			s = sc.next();
			if(s.equals("+")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n1+n2);
			}
			else if(s.equals("-")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n2-n1);
			}
			else if(s.equals("*")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n1 * n2);
			}
			else{
				stk.push(Integer.valueOf(s));
			}
		}
		cout(stk.pop());
	}
	
	
	
	public static boolean isPrime(int n){
		for(int i=2;i<=n*n;i++){
			if(n%i==0) return true;
		}
		return false;
	}
	public static int gcd(int a,int b){
		if(a%b==0) return b;
		else return gcd(b,a%b);
	}
	public static void showary(int[] ary){
		for(int i=0;i<ary.length-1;i++){
			System.out.print(ary[i]+" ");
		}
		cout(ary[ary.length-1]);
	}
	public static void cout(String n){
		System.out.println(n);
	}
	
	public static void cout(int n){
		System.out.println(n);
	}
	public static void cout(boolean n){
		if(n==true){
			cout("true");
		}else{
			cout("false");
		}
	}
} Main
import java.util.*;
 
public class Main {
	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		Stack<Integer> stk = new Stack<Integer>();
		String s;
		while(sc.hasNext()){
			s = sc.next();
			if(s.equals("+")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n1+n2);
			}
			else if(s.equals("-")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n2-n1);
			}
			else if(s.equals("*")){
				int n1 = stk.pop();
				int n2 = stk.pop();
				stk.push(n1 * n2);
			}
			else{
				stk.push(Integer.valueOf(s));
			}
		}
		cout(stk.pop());
	}
	
	
	
	public static boolean isPrime(int n){
		for(int i=2;i<=n*n;i++){
			if(n%i==0) return true;
		}
		return false;
	}
	public static int gcd(int a,int b){
		if(a%b==0) return b;
		else return gcd(b,a%b);
	}
	public static void showary(int[] ary){
		for(int i=0;i<ary.length-1;i++){
			System.out.print(ary[i]+" ");
		}
		cout(ary[ary.length-1]);
	}
	public static void cout(String n){
		System.out.println(n);
	}
	
	public static void cout(int n){
		System.out.println(n);
	}
	public static void cout(boolean n){
		if(n==true){
			cout("true");
		}else{
			cout("false");
		}
	}
}