import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	private static Scanner sc;
	public static void main(String[] args){
		sc=new Scanner(System.in);
		LinkedList<Integer> S = new LinkedList<Integer>();
		String x;
		while(sc.hasNext()){
			x=sc.next();
			if(x.charAt(0)=='+'){
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(a+b);
			}
			if(x.charAt(0)=='-'){
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(b-a);
			}
			if(x.charAt(0)=='*'){
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(a*b);
			}else if('0'<=x.charAt(0) && x.charAt(0)<='9'){
				S.push(Integer.parseInt(x));
			}
		}
		System.out.println(S.pop());
	}

} import java.util.LinkedList; LinkedList java.util import java.util.Scanner; Scanner java.util public class Main {
	private static Scanner sc;
	public static void main(String[] args){
		sc=new Scanner(System.in);
		LinkedList<Integer> S = new LinkedList<Integer>();
		String x;
		while(sc.hasNext()){
			x=sc.next();
			if(x.charAt(0)=='+'){
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(a+b);
			}
			if(x.charAt(0)=='-'){
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(b-a);
			}
			if(x.charAt(0)=='*'){
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(a*b);
			}else if('0'<=x.charAt(0) && x.charAt(0)<='9'){
				S.push(Integer.parseInt(x));
			}
		}
		System.out.println(S.pop());
	}

} Main private static Scanner sc; sc public static void main(String[] args){
		sc=new Scanner(System.in);
		LinkedList<Integer> S = new LinkedList<Integer>();
		String x;
		while(sc.hasNext()){
			x=sc.next();
			if(x.charAt(0)=='+'){
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(a+b);
			}
			if(x.charAt(0)=='-'){
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(b-a);
			}
			if(x.charAt(0)=='*'){
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(a*b);
			}else if('0'<=x.charAt(0) && x.charAt(0)<='9'){
				S.push(Integer.parseInt(x));
			}
		}
		System.out.println(S.pop());
	} main {
		sc=new Scanner(System.in);
		LinkedList<Integer> S = new LinkedList<Integer>();
		String x;
		while(sc.hasNext()){
			x=sc.next();
			if(x.charAt(0)=='+'){
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(a+b);
			}
			if(x.charAt(0)=='-'){
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(b-a);
			}
			if(x.charAt(0)=='*'){
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(a*b);
			}else if('0'<=x.charAt(0) && x.charAt(0)<='9'){
				S.push(Integer.parseInt(x));
			}
		}
		System.out.println(S.pop());
	} sc=new Scanner(System.in) sc new Scanner(System.in) LinkedList<Integer> S = new LinkedList<Integer>(); S new LinkedList<Integer>() String x; x while(sc.hasNext()){
			x=sc.next();
			if(x.charAt(0)=='+'){
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(a+b);
			}
			if(x.charAt(0)=='-'){
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(b-a);
			}
			if(x.charAt(0)=='*'){
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(a*b);
			}else if('0'<=x.charAt(0) && x.charAt(0)<='9'){
				S.push(Integer.parseInt(x));
			}
		} sc.hasNext() sc.hasNext sc {
			x=sc.next();
			if(x.charAt(0)=='+'){
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(a+b);
			}
			if(x.charAt(0)=='-'){
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(b-a);
			}
			if(x.charAt(0)=='*'){
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(a*b);
			}else if('0'<=x.charAt(0) && x.charAt(0)<='9'){
				S.push(Integer.parseInt(x));
			}
		} x=sc.next() x sc.next() sc.next sc if(x.charAt(0)=='+'){
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(a+b);
			} x.charAt(0)=='+' x.charAt(0) x.charAt x 0 '+' {
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(a+b);
			} int a=(int) S.pop(); a (int) S.pop() S.pop S int b=(int) S.pop(); b (int) S.pop() S.pop S S.push(a+b) S.push S a+b a b if(x.charAt(0)=='-'){
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(b-a);
			} x.charAt(0)=='-' x.charAt(0) x.charAt x 0 '-' {
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(b-a);
			} int a=(int) S.pop(); a (int) S.pop() S.pop S int b=(int) S.pop(); b (int) S.pop() S.pop S S.push(b-a) S.push S b-a b a if(x.charAt(0)=='*'){
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(a*b);
			}else if('0'<=x.charAt(0) && x.charAt(0)<='9'){
				S.push(Integer.parseInt(x));
			} x.charAt(0)=='*' x.charAt(0) x.charAt x 0 '*' {
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(a*b);
			} int a=(int) S.pop(); a (int) S.pop() S.pop S int b=(int) S.pop(); b (int) S.pop() S.pop S S.push(a*b) S.push S a*b a b if('0'<=x.charAt(0) && x.charAt(0)<='9'){
				S.push(Integer.parseInt(x));
			} '0'<=x.charAt(0) && x.charAt(0)<='9' '0'<=x.charAt(0) '0' x.charAt(0) x.charAt x 0 x.charAt(0)<='9' x.charAt(0) x.charAt x 0 '9' {
				S.push(Integer.parseInt(x));
			} S.push(Integer.parseInt(x)) S.push S Integer.parseInt(x) Integer.parseInt Integer x System.out.println(S.pop()) System.out.println System.out System System.out S.pop() S.pop S String[] args args public class Main {
	private static Scanner sc;
	public static void main(String[] args){
		sc=new Scanner(System.in);
		LinkedList<Integer> S = new LinkedList<Integer>();
		String x;
		while(sc.hasNext()){
			x=sc.next();
			if(x.charAt(0)=='+'){
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(a+b);
			}
			if(x.charAt(0)=='-'){
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(b-a);
			}
			if(x.charAt(0)=='*'){
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(a*b);
			}else if('0'<=x.charAt(0) && x.charAt(0)<='9'){
				S.push(Integer.parseInt(x));
			}
		}
		System.out.println(S.pop());
	}

} public class Main {
	private static Scanner sc;
	public static void main(String[] args){
		sc=new Scanner(System.in);
		LinkedList<Integer> S = new LinkedList<Integer>();
		String x;
		while(sc.hasNext()){
			x=sc.next();
			if(x.charAt(0)=='+'){
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(a+b);
			}
			if(x.charAt(0)=='-'){
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(b-a);
			}
			if(x.charAt(0)=='*'){
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(a*b);
			}else if('0'<=x.charAt(0) && x.charAt(0)<='9'){
				S.push(Integer.parseInt(x));
			}
		}
		System.out.println(S.pop());
	}

} Main
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	private static Scanner sc;
	public static void main(String[] args){
		sc=new Scanner(System.in);
		LinkedList<Integer> S = new LinkedList<Integer>();
		String x;
		while(sc.hasNext()){
			x=sc.next();
			if(x.charAt(0)=='+'){
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(a+b);
			}
			if(x.charAt(0)=='-'){
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(b-a);
			}
			if(x.charAt(0)=='*'){
				int a=(int) S.pop();
				int b=(int) S.pop();
				S.push(a*b);
			}else if('0'<=x.charAt(0) && x.charAt(0)<='9'){
				S.push(Integer.parseInt(x));
			}
		}
		System.out.println(S.pop());
	}

}