import java.util.Stack;
public class Solution {
public int evalRPN(String[] tokens) {
Stack<Integer> stack = new Stack<>();
for (int i=0;i<tokens.length;i++){
String str = tokens[i];
if(str.equals("+")){
int num1 = stack.pop();
int num2 = stack.pop();
stack.push(num1+num2);
}else if(str.equals("-")){
int num1 = stack.pop();
int num2 = stack.pop();
stack.push(num2-num1);
}else if(str.equals("*")){
int num1 = stack.pop();
int num2 = stack.pop();
stack.push(num2*num1);
}else if(str.equals("/")){
int num1 = stack.pop();
int num2 = stack.pop();
stack.push(num2/num1);
}else{
int num = Integer.parseInt(str);
stack.push(num);
}
}
return stack.peek();
}
}