
public class postfix {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String post = "52+32*-";
		IntStack stack = new IntStack(post.length());
		char op;
		int op1=0 , op2=0;
		for(int i=0; i<post.length();i++){
			op = post.charAt(i);
			if(op=='+'){
				op1=stack.pop();
				op2=stack.pop();
				stack.push(op2+op1);
			}else if(op=='-'){
				op1=stack.pop();
				op2=stack.pop();
				stack.push(op2-op1);
			}else if(op=='*'){
				op1=stack.pop();
				op2=stack.pop();
				stack.push(op2*op1);
			}else if(op=='/'){
				op1=stack.pop();
				op2=stack.pop();
				stack.push(op2/op1);
			}else{
				int toInt = Character.getNumericValue(op);
				stack.push(toInt);
			}				
		}
		System.out.println(stack.pop());
	}

}
