import java.util.Stack;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

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

	Stack <Integer>s1 = new Stack<Integer>();
	int a = 0;
int b = 0;

	for(int i = 0; i < S.length; i++)
	    {
		switch(S[i])
		    {
		    case "+":
			a = s1.pop();
			b = s1.pop();
			s1.add(a + b);
			continue;

		    case "-":
			a = s1.pop();
			b = s1.pop();
			s1.add(b - a);
			continue;

		    case "*":
			a = s1.pop();
			b = s1.pop();
			s1.add(a * b);
			continue;
		    }
		s1.push(Integer.parseInt(S[i]));
	    }
	System.out.println(s1.pop());
    }
} import java.util.Stack; Stack java.util import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.IOException; IOException java.io public class Main
{
    public static void main(String[] args)throws IOException
    {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] S = br.readLine().split("\\s");

	Stack <Integer>s1 = new Stack<Integer>();
	int a = 0;
int b = 0;

	for(int i = 0; i < S.length; i++)
	    {
		switch(S[i])
		    {
		    case "+":
			a = s1.pop();
			b = s1.pop();
			s1.add(a + b);
			continue;

		    case "-":
			a = s1.pop();
			b = s1.pop();
			s1.add(b - a);
			continue;

		    case "*":
			a = s1.pop();
			b = s1.pop();
			s1.add(a * b);
			continue;
		    }
		s1.push(Integer.parseInt(S[i]));
	    }
	System.out.println(s1.pop());
    }
} Main public static void main(String[] args)throws IOException
    {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] S = br.readLine().split("\\s");

	Stack <Integer>s1 = new Stack<Integer>();
	int a = 0;
int b = 0;

	for(int i = 0; i < S.length; i++)
	    {
		switch(S[i])
		    {
		    case "+":
			a = s1.pop();
			b = s1.pop();
			s1.add(a + b);
			continue;

		    case "-":
			a = s1.pop();
			b = s1.pop();
			s1.add(b - a);
			continue;

		    case "*":
			a = s1.pop();
			b = s1.pop();
			s1.add(a * b);
			continue;
		    }
		s1.push(Integer.parseInt(S[i]));
	    }
	System.out.println(s1.pop());
    } main {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] S = br.readLine().split("\\s");

	Stack <Integer>s1 = new Stack<Integer>();
	int a = 0;
int b = 0;

	for(int i = 0; i < S.length; i++)
	    {
		switch(S[i])
		    {
		    case "+":
			a = s1.pop();
			b = s1.pop();
			s1.add(a + b);
			continue;

		    case "-":
			a = s1.pop();
			b = s1.pop();
			s1.add(b - a);
			continue;

		    case "*":
			a = s1.pop();
			b = s1.pop();
			s1.add(a * b);
			continue;
		    }
		s1.push(Integer.parseInt(S[i]));
	    }
	System.out.println(s1.pop());
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] S = br.readLine().split("\\s"); S br.readLine().split("\\s") br.readLine().split br.readLine() br.readLine br "\\s" Stack <Integer>s1 = new Stack<Integer>(); s1 new Stack<Integer>() int a = 0; a 0 int b = 0; b 0 for(int i = 0; i < S.length; i++)
	    {
		switch(S[i])
		    {
		    case "+":
			a = s1.pop();
			b = s1.pop();
			s1.add(a + b);
			continue;

		    case "-":
			a = s1.pop();
			b = s1.pop();
			s1.add(b - a);
			continue;

		    case "*":
			a = s1.pop();
			b = s1.pop();
			s1.add(a * b);
			continue;
		    }
		s1.push(Integer.parseInt(S[i]));
	    } int i = 0; int i = 0; i 0 i < S.length i S.length S S.length i++ i++ i {
		switch(S[i])
		    {
		    case "+":
			a = s1.pop();
			b = s1.pop();
			s1.add(a + b);
			continue;

		    case "-":
			a = s1.pop();
			b = s1.pop();
			s1.add(b - a);
			continue;

		    case "*":
			a = s1.pop();
			b = s1.pop();
			s1.add(a * b);
			continue;
		    }
		s1.push(Integer.parseInt(S[i]));
	    } {
		switch(S[i])
		    {
		    case "+":
			a = s1.pop();
			b = s1.pop();
			s1.add(a + b);
			continue;

		    case "-":
			a = s1.pop();
			b = s1.pop();
			s1.add(b - a);
			continue;

		    case "*":
			a = s1.pop();
			b = s1.pop();
			s1.add(a * b);
			continue;
		    }
		s1.push(Integer.parseInt(S[i]));
	    } switch(S[i])
		    {
		    case "+":
			a = s1.pop();
			b = s1.pop();
			s1.add(a + b);
			continue;

		    case "-":
			a = s1.pop();
			b = s1.pop();
			s1.add(b - a);
			continue;

		    case "*":
			a = s1.pop();
			b = s1.pop();
			s1.add(a * b);
			continue;
		    } S[i] S i case "+": "+" case "+": a = s1.pop() a s1.pop() s1.pop s1 b = s1.pop() b s1.pop() s1.pop s1 s1.add(a + b) s1.add s1 a + b a b continue; case "-": "-" case "-": a = s1.pop() a s1.pop() s1.pop s1 b = s1.pop() b s1.pop() s1.pop s1 s1.add(b - a) s1.add s1 b - a b a continue; case "*": "*" case "*": a = s1.pop() a s1.pop() s1.pop s1 b = s1.pop() b s1.pop() s1.pop s1 s1.add(a * b) s1.add s1 a * b a b continue; s1.push(Integer.parseInt(S[i])) s1.push s1 Integer.parseInt(S[i]) Integer.parseInt Integer S[i] S i System.out.println(s1.pop()) System.out.println System.out System System.out s1.pop() s1.pop s1 String[] args args public class Main
{
    public static void main(String[] args)throws IOException
    {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] S = br.readLine().split("\\s");

	Stack <Integer>s1 = new Stack<Integer>();
	int a = 0;
int b = 0;

	for(int i = 0; i < S.length; i++)
	    {
		switch(S[i])
		    {
		    case "+":
			a = s1.pop();
			b = s1.pop();
			s1.add(a + b);
			continue;

		    case "-":
			a = s1.pop();
			b = s1.pop();
			s1.add(b - a);
			continue;

		    case "*":
			a = s1.pop();
			b = s1.pop();
			s1.add(a * b);
			continue;
		    }
		s1.push(Integer.parseInt(S[i]));
	    }
	System.out.println(s1.pop());
    }
} public class Main
{
    public static void main(String[] args)throws IOException
    {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] S = br.readLine().split("\\s");

	Stack <Integer>s1 = new Stack<Integer>();
	int a = 0;
int b = 0;

	for(int i = 0; i < S.length; i++)
	    {
		switch(S[i])
		    {
		    case "+":
			a = s1.pop();
			b = s1.pop();
			s1.add(a + b);
			continue;

		    case "-":
			a = s1.pop();
			b = s1.pop();
			s1.add(b - a);
			continue;

		    case "*":
			a = s1.pop();
			b = s1.pop();
			s1.add(a * b);
			continue;
		    }
		s1.push(Integer.parseInt(S[i]));
	    }
	System.out.println(s1.pop());
    }
} Main
import java.util.Stack;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

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

	Stack <Integer>s1 = new Stack<Integer>();
	int a = 0;
int b = 0;

	for(int i = 0; i < S.length; i++)
	    {
		switch(S[i])
		    {
		    case "+":
			a = s1.pop();
			b = s1.pop();
			s1.add(a + b);
			continue;

		    case "-":
			a = s1.pop();
			b = s1.pop();
			s1.add(b - a);
			continue;

		    case "*":
			a = s1.pop();
			b = s1.pop();
			s1.add(a * b);
			continue;
		    }
		s1.push(Integer.parseInt(S[i]));
	    }
	System.out.println(s1.pop());
    }
}