import java.util.Scanner;
class Main
{
	static class Stack
	{
		int A[], head;
		Stack( int size )
		{
			A = new int[size+1];
			head = 0;
		}
		void show()
		{
			for( int i = 1 ; i < A.length ; i++ )
				if( i==A.length-1 )System.out.println(A[i]);
				else System.out.print(A[i]+" ");
		}
		boolean isEmpty(){return head==0;}
		boolean isFull( ){return head==A.length-1;}
		void push( int key )
		{
			if( isFull() )return;
			A[++head] = key;
		}
		int pop()
		{
			if( isEmpty() )return 0;
			return A[head--];
		}
	}
	public static void main( String[] args )
	{
		Scanner sc = new Scanner( System.in );
		String com;
		Stack stack = new Stack(100);
		while( sc.hasNext() )
		{
			com = sc.next();
			
			if( com.equals("+") )
				stack.push( stack.pop()+stack.pop() );
			else if( com.equals("-") )
				stack.push( -1*stack.pop()+stack.pop() );
			else if( com.equals("*") )
				stack.push( stack.pop()*stack.pop() );
			else
				stack.push(Integer.parseInt(com));
		}
		System.out.println( stack.pop() );
	}
} import java.util.Scanner; Scanner java.util class Main
{
	static class Stack
	{
		int A[], head;
		Stack( int size )
		{
			A = new int[size+1];
			head = 0;
		}
		void show()
		{
			for( int i = 1 ; i < A.length ; i++ )
				if( i==A.length-1 )System.out.println(A[i]);
				else System.out.print(A[i]+" ");
		}
		boolean isEmpty(){return head==0;}
		boolean isFull( ){return head==A.length-1;}
		void push( int key )
		{
			if( isFull() )return;
			A[++head] = key;
		}
		int pop()
		{
			if( isEmpty() )return 0;
			return A[head--];
		}
	}
	public static void main( String[] args )
	{
		Scanner sc = new Scanner( System.in );
		String com;
		Stack stack = new Stack(100);
		while( sc.hasNext() )
		{
			com = sc.next();
			
			if( com.equals("+") )
				stack.push( stack.pop()+stack.pop() );
			else if( com.equals("-") )
				stack.push( -1*stack.pop()+stack.pop() );
			else if( com.equals("*") )
				stack.push( stack.pop()*stack.pop() );
			else
				stack.push(Integer.parseInt(com));
		}
		System.out.println( stack.pop() );
	}
} Main public static void main( String[] args )
	{
		Scanner sc = new Scanner( System.in );
		String com;
		Stack stack = new Stack(100);
		while( sc.hasNext() )
		{
			com = sc.next();
			
			if( com.equals("+") )
				stack.push( stack.pop()+stack.pop() );
			else if( com.equals("-") )
				stack.push( -1*stack.pop()+stack.pop() );
			else if( com.equals("*") )
				stack.push( stack.pop()*stack.pop() );
			else
				stack.push(Integer.parseInt(com));
		}
		System.out.println( stack.pop() );
	} main {
		Scanner sc = new Scanner( System.in );
		String com;
		Stack stack = new Stack(100);
		while( sc.hasNext() )
		{
			com = sc.next();
			
			if( com.equals("+") )
				stack.push( stack.pop()+stack.pop() );
			else if( com.equals("-") )
				stack.push( -1*stack.pop()+stack.pop() );
			else if( com.equals("*") )
				stack.push( stack.pop()*stack.pop() );
			else
				stack.push(Integer.parseInt(com));
		}
		System.out.println( stack.pop() );
	} Scanner sc = new Scanner( System.in ); sc new Scanner( System.in ) String com; com Stack stack = new Stack(100); stack new Stack(100) while( sc.hasNext() )
		{
			com = sc.next();
			
			if( com.equals("+") )
				stack.push( stack.pop()+stack.pop() );
			else if( com.equals("-") )
				stack.push( -1*stack.pop()+stack.pop() );
			else if( com.equals("*") )
				stack.push( stack.pop()*stack.pop() );
			else
				stack.push(Integer.parseInt(com));
		} sc.hasNext() sc.hasNext sc {
			com = sc.next();
			
			if( com.equals("+") )
				stack.push( stack.pop()+stack.pop() );
			else if( com.equals("-") )
				stack.push( -1*stack.pop()+stack.pop() );
			else if( com.equals("*") )
				stack.push( stack.pop()*stack.pop() );
			else
				stack.push(Integer.parseInt(com));
		} com = sc.next() com sc.next() sc.next sc if( com.equals("+") )
				stack.push( stack.pop()+stack.pop() );
			else if( com.equals("-") )
				stack.push( -1*stack.pop()+stack.pop() );
			else if( com.equals("*") )
				stack.push( stack.pop()*stack.pop() );
			else
				stack.push(Integer.parseInt(com)); com.equals("+") com.equals com "+" stack.push( stack.pop()+stack.pop() ) stack.push stack stack.pop()+stack.pop() stack.pop() stack.pop stack stack.pop() stack.pop stack if( com.equals("-") )
				stack.push( -1*stack.pop()+stack.pop() );
			else if( com.equals("*") )
				stack.push( stack.pop()*stack.pop() );
			else
				stack.push(Integer.parseInt(com)); com.equals("-") com.equals com "-" stack.push( -1*stack.pop()+stack.pop() ) stack.push stack -1*stack.pop()+stack.pop() -1*stack.pop() -1 1 stack.pop() stack.pop stack stack.pop() stack.pop stack if( com.equals("*") )
				stack.push( stack.pop()*stack.pop() );
			else
				stack.push(Integer.parseInt(com)); com.equals("*") com.equals com "*" stack.push( stack.pop()*stack.pop() ) stack.push stack stack.pop()*stack.pop() stack.pop() stack.pop stack stack.pop() stack.pop stack stack.push(Integer.parseInt(com)) stack.push stack Integer.parseInt(com) Integer.parseInt Integer com System.out.println( stack.pop() ) System.out.println System.out System System.out stack.pop() stack.pop stack String[] args args static class Stack
	{
		int A[], head;
		Stack( int size )
		{
			A = new int[size+1];
			head = 0;
		}
		void show()
		{
			for( int i = 1 ; i < A.length ; i++ )
				if( i==A.length-1 )System.out.println(A[i]);
				else System.out.print(A[i]+" ");
		}
		boolean isEmpty(){return head==0;}
		boolean isFull( ){return head==A.length-1;}
		void push( int key )
		{
			if( isFull() )return;
			A[++head] = key;
		}
		int pop()
		{
			if( isEmpty() )return 0;
			return A[head--];
		}
	} Stack int A[] A head; head Stack( int size )
		{
			A = new int[size+1];
			head = 0;
		} Stack {
			A = new int[size+1];
			head = 0;
		} A = new int[size+1] A new int[size+1] size+1 size 1 head = 0 head 0 int size size void show()
		{
			for( int i = 1 ; i < A.length ; i++ )
				if( i==A.length-1 )System.out.println(A[i]);
				else System.out.print(A[i]+" ");
		} show {
			for( int i = 1 ; i < A.length ; i++ )
				if( i==A.length-1 )System.out.println(A[i]);
				else System.out.print(A[i]+" ");
		} for( int i = 1 ; i < A.length ; i++ )
				if( i==A.length-1 )System.out.println(A[i]);
				else System.out.print(A[i]+" "); int i = 1 ; int i = 1 ; i 1 i < A.length i A.length A A.length i++ i++ i if( i==A.length-1 )System.out.println(A[i]);
				else System.out.print(A[i]+" "); if( i==A.length-1 )System.out.println(A[i]);
				else System.out.print(A[i]+" "); i==A.length-1 i A.length-1 A.length A A.length 1 System.out.println(A[i]) System.out.println System.out System System.out A[i] A i System.out.print(A[i]+" ") System.out.print System.out System System.out A[i]+" " A[i] A i " " boolean isEmpty(){return head==0;} isEmpty {return head==0;} return head==0; head==0 head 0 boolean isFull( ){return head==A.length-1;} isFull {return head==A.length-1;} return head==A.length-1; head==A.length-1 head A.length-1 A.length A A.length 1 void push( int key )
		{
			if( isFull() )return;
			A[++head] = key;
		} push {
			if( isFull() )return;
			A[++head] = key;
		} if( isFull() )return; isFull() isFull return; A[++head] = key A[++head] A ++head head key int key key int pop()
		{
			if( isEmpty() )return 0;
			return A[head--];
		} pop {
			if( isEmpty() )return 0;
			return A[head--];
		} if( isEmpty() )return 0; isEmpty() isEmpty return 0; 0 return A[head--]; A[head--] A head-- head
import java.util.Scanner;
class Main
{
	static class Stack
	{
		int A[], head;
		Stack( int size )
		{
			A = new int[size+1];
			head = 0;
		}
		void show()
		{
			for( int i = 1 ; i < A.length ; i++ )
				if( i==A.length-1 )System.out.println(A[i]);
				else System.out.print(A[i]+" ");
		}
		boolean isEmpty(){return head==0;}
		boolean isFull( ){return head==A.length-1;}
		void push( int key )
		{
			if( isFull() )return;
			A[++head] = key;
		}
		int pop()
		{
			if( isEmpty() )return 0;
			return A[head--];
		}
	}
	public static void main( String[] args )
	{
		Scanner sc = new Scanner( System.in );
		String com;
		Stack stack = new Stack(100);
		while( sc.hasNext() )
		{
			com = sc.next();
			
			if( com.equals("+") )
				stack.push( stack.pop()+stack.pop() );
			else if( com.equals("-") )
				stack.push( -1*stack.pop()+stack.pop() );
			else if( com.equals("*") )
				stack.push( stack.pop()*stack.pop() );
			else
				stack.push(Integer.parseInt(com));
		}
		System.out.println( stack.pop() );
	}
}