import java.io.*;
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        Deque<String> formula = new ArrayDeque<String>();
        Scanner scan = new Scanner(System.in);

        while(scan.hasNext())
        {
            String input = scan.next();
            int num2,num1;

            if(input.equals("+"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1+num2));
            }
            else if(input.equals("*"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1*num2));
            }
            else if(input.equals("-"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1-num2));                
            }
            else if(input.equals("="))
            {
                break;
            }
            else
            {
                formula.push(input);
            }
            int size = formula.size();
            for(int i = 0; i<size; i++)
            {
                String p = formula.pollLast();
//                System.out.printf("%s ",p);
                formula.push(p);
            }
//            System.out.println();
        }
        System.out.println(formula.poll());
    }
} import java.io.*; io.* java import java.util.*; util.* java public class Main
{
    public static void main(String[] args)
    {
        Deque<String> formula = new ArrayDeque<String>();
        Scanner scan = new Scanner(System.in);

        while(scan.hasNext())
        {
            String input = scan.next();
            int num2,num1;

            if(input.equals("+"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1+num2));
            }
            else if(input.equals("*"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1*num2));
            }
            else if(input.equals("-"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1-num2));                
            }
            else if(input.equals("="))
            {
                break;
            }
            else
            {
                formula.push(input);
            }
            int size = formula.size();
            for(int i = 0; i<size; i++)
            {
                String p = formula.pollLast();
//                System.out.printf("%s ",p);
                formula.push(p);
            }
//            System.out.println();
        }
        System.out.println(formula.poll());
    }
} Main public static void main(String[] args)
    {
        Deque<String> formula = new ArrayDeque<String>();
        Scanner scan = new Scanner(System.in);

        while(scan.hasNext())
        {
            String input = scan.next();
            int num2,num1;

            if(input.equals("+"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1+num2));
            }
            else if(input.equals("*"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1*num2));
            }
            else if(input.equals("-"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1-num2));                
            }
            else if(input.equals("="))
            {
                break;
            }
            else
            {
                formula.push(input);
            }
            int size = formula.size();
            for(int i = 0; i<size; i++)
            {
                String p = formula.pollLast();
//                System.out.printf("%s ",p);
                formula.push(p);
            }
//            System.out.println();
        }
        System.out.println(formula.poll());
    } main {
        Deque<String> formula = new ArrayDeque<String>();
        Scanner scan = new Scanner(System.in);

        while(scan.hasNext())
        {
            String input = scan.next();
            int num2,num1;

            if(input.equals("+"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1+num2));
            }
            else if(input.equals("*"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1*num2));
            }
            else if(input.equals("-"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1-num2));                
            }
            else if(input.equals("="))
            {
                break;
            }
            else
            {
                formula.push(input);
            }
            int size = formula.size();
            for(int i = 0; i<size; i++)
            {
                String p = formula.pollLast();
//                System.out.printf("%s ",p);
                formula.push(p);
            }
//            System.out.println();
        }
        System.out.println(formula.poll());
    } Deque<String> formula = new ArrayDeque<String>(); formula new ArrayDeque<String>() Scanner scan = new Scanner(System.in); scan new Scanner(System.in) while(scan.hasNext())
        {
            String input = scan.next();
            int num2,num1;

            if(input.equals("+"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1+num2));
            }
            else if(input.equals("*"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1*num2));
            }
            else if(input.equals("-"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1-num2));                
            }
            else if(input.equals("="))
            {
                break;
            }
            else
            {
                formula.push(input);
            }
            int size = formula.size();
            for(int i = 0; i<size; i++)
            {
                String p = formula.pollLast();
//                System.out.printf("%s ",p);
                formula.push(p);
            }
//            System.out.println();
        } scan.hasNext() scan.hasNext scan {
            String input = scan.next();
            int num2,num1;

            if(input.equals("+"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1+num2));
            }
            else if(input.equals("*"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1*num2));
            }
            else if(input.equals("-"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1-num2));                
            }
            else if(input.equals("="))
            {
                break;
            }
            else
            {
                formula.push(input);
            }
            int size = formula.size();
            for(int i = 0; i<size; i++)
            {
                String p = formula.pollLast();
//                System.out.printf("%s ",p);
                formula.push(p);
            }
//            System.out.println();
        } String input = scan.next(); input scan.next() scan.next scan int num2 num2 num1; num1 if(input.equals("+"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1+num2));
            }
            else if(input.equals("*"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1*num2));
            }
            else if(input.equals("-"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1-num2));                
            }
            else if(input.equals("="))
            {
                break;
            }
            else
            {
                formula.push(input);
            } input.equals("+") input.equals input "+" {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1+num2));
            } num2 = Integer.parseInt(formula.poll()) num2 Integer.parseInt(formula.poll()) Integer.parseInt Integer formula.poll() formula.poll formula num1 = Integer.parseInt(formula.poll()) num1 Integer.parseInt(formula.poll()) Integer.parseInt Integer formula.poll() formula.poll formula formula.push(String.valueOf(num1+num2)) formula.push formula String.valueOf(num1+num2) String.valueOf String num1+num2 num1 num2 if(input.equals("*"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1*num2));
            }
            else if(input.equals("-"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1-num2));                
            }
            else if(input.equals("="))
            {
                break;
            }
            else
            {
                formula.push(input);
            } input.equals("*") input.equals input "*" {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1*num2));
            } num2 = Integer.parseInt(formula.poll()) num2 Integer.parseInt(formula.poll()) Integer.parseInt Integer formula.poll() formula.poll formula num1 = Integer.parseInt(formula.poll()) num1 Integer.parseInt(formula.poll()) Integer.parseInt Integer formula.poll() formula.poll formula formula.push(String.valueOf(num1*num2)) formula.push formula String.valueOf(num1*num2) String.valueOf String num1*num2 num1 num2 if(input.equals("-"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1-num2));                
            }
            else if(input.equals("="))
            {
                break;
            }
            else
            {
                formula.push(input);
            } input.equals("-") input.equals input "-" {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1-num2));                
            } num2 = Integer.parseInt(formula.poll()) num2 Integer.parseInt(formula.poll()) Integer.parseInt Integer formula.poll() formula.poll formula num1 = Integer.parseInt(formula.poll()) num1 Integer.parseInt(formula.poll()) Integer.parseInt Integer formula.poll() formula.poll formula formula.push(String.valueOf(num1-num2)) formula.push formula String.valueOf(num1-num2) String.valueOf String num1-num2 num1 num2 if(input.equals("="))
            {
                break;
            }
            else
            {
                formula.push(input);
            } input.equals("=") input.equals input "=" {
                break;
            } break; {
                formula.push(input);
            } formula.push(input) formula.push formula input int size = formula.size(); size formula.size() formula.size formula for(int i = 0; i<size; i++)
            {
                String p = formula.pollLast();
//                System.out.printf("%s ",p);
                formula.push(p);
            } int i = 0; int i = 0; i 0 i<size i size i++ i++ i {
                String p = formula.pollLast();
//                System.out.printf("%s ",p);
                formula.push(p);
            } {
                String p = formula.pollLast();
//                System.out.printf("%s ",p);
                formula.push(p);
            } String p = formula.pollLast(); p formula.pollLast() formula.pollLast formula formula.push(p) formula.push formula p System.out.println(formula.poll()) System.out.println System.out System System.out formula.poll() formula.poll formula String[] args args public class Main
{
    public static void main(String[] args)
    {
        Deque<String> formula = new ArrayDeque<String>();
        Scanner scan = new Scanner(System.in);

        while(scan.hasNext())
        {
            String input = scan.next();
            int num2,num1;

            if(input.equals("+"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1+num2));
            }
            else if(input.equals("*"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1*num2));
            }
            else if(input.equals("-"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1-num2));                
            }
            else if(input.equals("="))
            {
                break;
            }
            else
            {
                formula.push(input);
            }
            int size = formula.size();
            for(int i = 0; i<size; i++)
            {
                String p = formula.pollLast();
//                System.out.printf("%s ",p);
                formula.push(p);
            }
//            System.out.println();
        }
        System.out.println(formula.poll());
    }
} public class Main
{
    public static void main(String[] args)
    {
        Deque<String> formula = new ArrayDeque<String>();
        Scanner scan = new Scanner(System.in);

        while(scan.hasNext())
        {
            String input = scan.next();
            int num2,num1;

            if(input.equals("+"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1+num2));
            }
            else if(input.equals("*"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1*num2));
            }
            else if(input.equals("-"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1-num2));                
            }
            else if(input.equals("="))
            {
                break;
            }
            else
            {
                formula.push(input);
            }
            int size = formula.size();
            for(int i = 0; i<size; i++)
            {
                String p = formula.pollLast();
//                System.out.printf("%s ",p);
                formula.push(p);
            }
//            System.out.println();
        }
        System.out.println(formula.poll());
    }
} Main
import java.io.*;
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        Deque<String> formula = new ArrayDeque<String>();
        Scanner scan = new Scanner(System.in);

        while(scan.hasNext())
        {
            String input = scan.next();
            int num2,num1;

            if(input.equals("+"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1+num2));
            }
            else if(input.equals("*"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1*num2));
            }
            else if(input.equals("-"))
            {
                num2 = Integer.parseInt(formula.poll());
                num1 = Integer.parseInt(formula.poll());
                formula.push(String.valueOf(num1-num2));                
            }
            else if(input.equals("="))
            {
                break;
            }
            else
            {
                formula.push(input);
            }
            int size = formula.size();
            for(int i = 0; i<size; i++)
            {
                String p = formula.pollLast();
//                System.out.printf("%s ",p);
                formula.push(p);
            }
//            System.out.println();
        }
        System.out.println(formula.poll());
    }
}