import java.util.*;
import java.io.*;

public class Q4
{
    public static void main(String[] args) throws IOException
    {
        Scanner in = new Scanner(new File("DATA4.txt"));
        PrintWriter out = new PrintWriter(new FileWriter("OUT4.txt"));
        String s;
        for (int i = 0; i < 5; i++)
        {
            s = in.nextLine();
            s = s.replaceAll(" ", "");
            s = s.replaceAll("-", "+-");
            s = s.replaceAll("[+][+]", "+");
            out.println(solve(s));
        }
        in.close();
        out.close();
    }
    
    public static int solve(String s)
    {
        System.out.println(s);
        try {
            return Integer.parseInt(s);
        }
        catch(Exception e){}
        if (s.indexOf('(') != -1) {
            return solve(s.substring(0, s.lastIndexOf('(', s.indexOf(')'))) +
                         solve(s.substring(s.lastIndexOf('(', s.indexOf(')'))+1, s.indexOf(')'))) +
                         s.substring( s.indexOf(')')+1));
        }
        if (s.indexOf('+') != -1) {
                return solve(s.substring(0, s.indexOf('+'))) + solve(s.substring(s.indexOf('+')+1));
            }
        if (s.indexOf('*') != -1 || s.indexOf('/') != -1 ) {
            if (s.indexOf('/') == -1 || s.indexOf('*') < s.indexOf('/') && s.indexOf('*') != -1) {
                return solve(s.substring(0, s.indexOf('*'))) * solve(s.substring(s.indexOf('*')+1));
            }
            else
                return solve(s.substring(0, s.indexOf('/'))) / solve(s.substring(s.indexOf('/')+1));
        }
        if (s.indexOf('^') != -1) {
            return Math.abs(solve("" + Math.abs(solve(s.substring(0, s.indexOf('^')))) +
                         Math.abs(solve(s.substring(s.indexOf('^')+1)))));
        }
        if (s.indexOf('-') != -1) {
            return solve(s.replaceAll("-", ""));
        }
        return 0;
    }
}
