import java.util.*;


public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param tokens string字符串一维数组 
     * @return int整型
     */
    public int evalRPN (String[] tokens) {
        // write code here
        Stack<Integer> s=new Stack<Integer>();
        int num1=0;
        int num2=0;
        for(int i=0;i<tokens.length;i++)
        {
            if(tokens[i].equals("+"))
            {
                num1=s.pop()+s.pop();
                s.push(num1);
            }else if(tokens[i].equals("-"))
            {
                num1=-(s.pop()-s.pop());
                s.push(num1);
            }else if(tokens[i].equals("*"))
            {
                num1=s.pop()*s.pop();
                s.push(num1);
            }else if(tokens[i].equals("/"))
            {
                num1=s.pop();
                num2=s.pop();
                num1=num2/num1;
                s.push(num1);
            }else{
                s.push(Integer.parseInt(tokens[i]));
            }
        }
        return s.peek();
    }
}