import java.util.*;


public class Solution {
    /**
     * 
     * @param tokens string字符串一维数组 
     * @return int整型
     */
    public int evalRPN (String[] tokens) {
        // write code here
        Stack<Integer> stack=new Stack();
        for(String token:tokens){
            if(isNumber(token)){
                stack.push(Integer.parseInt(token));
            }else{
                int a=stack.pop();
                int b=stack.pop();
                switch(token){
                    case "+": stack.push(a+b);break;
                    case "-": stack.push(a-b);break;
                    case "*": stack.push(a*b);break;
                    case "/": stack.push(a/b);break;
                    default: throw new IllegalArgumentException("未知参数");
                }
            }
        }

        return stack.pop();


    }

    public boolean isNumber(String param){
        try{
                Integer.parseInt(param);
        }catch(Exception e){
return false;
        }
        return true;
    }
}