#include <bits/stdc++.h>
using namespace std;
char Z[10000000];
int N[10000000];
int topZ=0,topN=0;
void Zin(char z){
Z[topZ++]=z;
}
char Zout(){
return Z[--topZ];
}
char Zsee(){
return Z[topZ-1];
}
void Nin(int n){
N[topN++]=n;
}
int Nout(){
return N[--topN];
}
int Nsee(){
return N[topN-1];
}
int priority(char op){
if(op=='^'){
return 3;
}
if(op=='*'||op=='/'){
return 2;
}
if(op=='+'||op=='-'){
return 1;
}
if(op=='('){
return 0;
}
}
int main(){
string x,n;
int T=0,TY=0;
cin>>x;
for(int i=0;i<x.size();i++){
if('0'<=x[i]&&x[i]<='9'){
n[T++]=x[i];
}
else{
if(x[i]=='('){
Zin(x[i]);
}
else if(x[i]==')'){
while(Zsee()!='('){
n[T++]=Zout();
}
Zout();
}
else{
int P=priority(x[i]);
while(priority(Zsee())>=P&&topZ>0){
n[T++]=Zout();
}
Zin(x[i]);
}
}
}
while(topZ!=0){
n[T++]=Zout();
}
TY=1;
for(int i=0;i<T;i++){
if(TY){
for(int j=0;j<topN;j++){
cout<<N[j]<<" ";
}
for(int j=i;j<T;j++){
cout<<n[j]<<" ";
}
cout<<endl;
}
if('0'<=n[i]&&n[i]<='9'){
Nin(n[i]-'0');
TY=0;
}
else{
int o1=Nout(),o2=Nout();
if(n[i]=='+'){
Nin(o1+o2);
}
else if(n[i]=='-'){
Nin(o2-o1);
}
else if(n[i]=='*'){
Nin(o1*o2);
}
else if(n[i]=='/'){
Nin(o2/o1);
}
else if(n[i]=='^'){
Nin(o2^o1);
}
TY=1;
}
}
cout<<int(Nout());
}