#include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <map>
using namespace std;
/*
int parse(string input)
{
while(input.find('(')!=string::npos)
{
int start;
int len;
start = input.find('(');
stack<char> brackets;
brackets.push('(');
for(int i=start+1;i<input.length()+1;i++)
{
if (input[i]=='(') brackets.push('(');
if (input[i]==')') brackets.pop();
if (brackets.empty()) { len = start-i; break; }
}
string inbrackets;
input.copy(inbrackets,start+1,len-1);
input.replace(start,len,atoi(parse(inbrackets)));
}
}*/
struct lexem
{
string lex;
string type;
};
int calc(string input)
{
queue<lexem> series;
string lex;
int dgt=0,opr=0,min=0;;
for(int i=0;i<input.length();i++)
{
if (!dgt&&!opr)
{
if (isdigit(input[i]))
{
dgt=1;
lex=input[i];
}
else if(input[i]=='(' || input[i]==')')
{
lex = input[i];
lexem l;
l.lex = lex;
l.type="bracket";
series.push(l);
lex.clear();
}
else
{
opr=1;
lex=input[i];
}
}
else if(dgt)
{
if (isdigit(input[i]))
{
lex+=input[i];
}
else
{
if (min) { lex="-"+lex; min=0; }
lexem l;
l.lex = lex;
l.type = "number";
series.push(l);
lex.clear();
dgt=0;
i-=1;
}
}
else if(opr)
{
if (isdigit(input[i]) || input[i]=='(' || input[i]==')')
{
opr=0;
lexem l;
l.type = "operation";
if (lex.length()>1 && lex[0]=='-')
{
min=1;
lex.erase(0,1);
l.lex=lex;
series.push(l);
}
else if (lex.length()>1 && lex[lex.length()-1]=='-')
{
min=1;
lex.erase(lex.length()-1,1);
l.lex=lex;
series.push(l);
}
else { l.lex = lex; series.push(l); }
lex.clear();
i-=1;
}
else
{
lex+=input[i];
}
}
}
if (lex.length())
{
lexem l;
l.lex = lex;
if (dgt) { l.type="number";
if (min) l.lex="-"+l.lex; }
else if(opr) l.type="operation";
else l.type="bracket";
series.push(l);
}
while (!series.empty())
{
cout << series.front().lex << " ";
series.pop();
}
cout << endl;
}
/*
int count(string input)
{
map<string,int> priority;
priority["+"]=0;
priority["-"]=0;
priority["*"]=1;
priority["/"]=1;
stack<op> operands;
stack<oper> operations;
int pos = 0;
while (pos<input.length())
{
int op =0;
while (isdigit(input[pos]))
{
op*=10;
op+=input[pos++]-48;
}
operands.push(op);
if (pos<input.length())
{
operations.push(input[pos++]);
}
}
int res=0;
//while (!operands.empty()) { cout<<operands.top() << " "; operands.pop(); }
//cout << endl;
//while (!operations.empty()) { cout<<operations.top() << " "; operations.pop(); }
while (!operations.empty())
{
char op = operations.top();
operations.pop();
int op1=operands.top();
operands.pop();
int op2=operands.top();
operands.pop();
switch(op)
{
case '+':
operands.push(op1+op2);
break;
case '-':
operands.push(op1-op2);
break;
case '*':
operands.push(op1*op2);
break;
}
}
return operands.top();
}*/
int main()
{
string input;
while (getline(cin,input))
{
cout << calc(input) << endl;
}
}