import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String str = in.nextLine();
in.close();
Stack<Character> opStack = new Stack<>();
Stack<Double> numStack = new Stack<>();
for (int i = 0; i < str.length(); i++) {
char ch = str.charAt(i);
if (ch == ' ') {
continue;
}
if (Character.isDigit(ch)) {
// 解析完整整数
double num = 0;
while (i < str.length() && Character.isDigit(str.charAt(i))) {
num = num * 10 + (str.charAt(i) - '0');
i++;
}
i--; // 循环结束后会自增,这里先减回去
numStack.push(num);
} else if (ch == '(') {
opStack.push(ch);
} else if (ch == ')') {
// 计算直到遇到左括号
while (opStack.peek() != '(') {
double b = numStack.pop();
double a = numStack.pop();
char op = opStack.pop();
numStack.push(calc(op, a, b));
}
opStack.pop(); // 弹出 '('
} else if (isOperator(ch)) {
// 当前运算符优先级不高于栈顶时,先计算栈顶
while (!opStack.isEmpty() && opStack.peek() != '(' &&
getPriority(opStack.peek()) >= getPriority(ch)) {
double b = numStack.pop();
double a = numStack.pop();
char op = opStack.pop();
numStack.push(calc(op, a, b));
}
opStack.push(ch);
}
}
// 处理剩余运算符
while (!opStack.isEmpty()) {
double b = numStack.pop();
double a = numStack.pop();
char op = opStack.pop();
numStack.push(calc(op, a, b));
}
// 输出结果
System.out.printf("%.2f",numStack.pop());
}
public static boolean isOperator(char c) {
return c == '+' || c == '-' || c == '*' || c == '/';
}
public static int getPriority(char c) {
if (c == '+' || c == '-') {
return 1;
} else if (c == '*' || c == '/') {
return 2;
}
return 0; // 括号优先级最低
}
public static double calc(char op, double a, double b) {
switch (op) {
case '+':
return a + b;
case '-':
return a - b;
case '*':
return a * b;
case '/':
return a / b;
default:
throw new IllegalArgumentException("非法运算符: " + op);
}
}
}