private static String calc(String s) {
        Stack<String> num = new Stack<String>();
        Stack<Character> op = new Stack<Character>();
        char[] cs = (s + "#").toCharArray();
        StringBuilder numV = new StringBuilder();
        boolean inputNum = false;
        op.push('#');
        int i = 0;
        while (cs[i] != '#' || op.peek() != '#') {
            char c = cs[i];
            if (isOp(c)) {
                if (inputNum) {
                    num.push(numV.toString());
                    numV.delete(0, numV.length());
                    inputNum = false;
                }
                if (op.isEmpty()) {
                    op.push(c);
                } else {
                    switch (compare(op.peek(), c)) {
                    case 0 :
                        op.pop();
                        break;
                    case -1 :
                        op.push(c);
                        break;
                    case 1 :
                        String num2 = num.pop();
                        String num1 = num.pop();
                        num.push(calculate(op.pop(), num1, num2));
                        continue;
                    }
                }
            } else {
                numV.append(c);
                inputNum = true;
            }
            if (c != '#') {
                i++;
            }
        }
        return num.pop();
    }