const
  deyst = ['+','*','/','-','(',')'];
  Copers : array [1..6] of char = ('+','-','*','/','(',')');
type
    ps  = ^el;
    el  = record
        data : integer;
        prev : ps;
    end;
var
   header : ps;
   polsk  : string;

Procedure MakeD(var num1:integer;num2:integer;dey:char);
begin
  case dey of
    '+': num1 := num1 + num2;
    '-': num1 := num1 - num2;
    '*': num1 := num1 * num2;
    '/': if num2 <> 0 then num1 := num1 div num2;
  end;
end;

Function GetOper(dey:char):integer;
begin
  case dey of
    '+': GetOper:=1;
    '-': GetOper:=2;
    '*': GetOper:=3;
    '/': GetOper:=4;
    '(': GetOper:=5;
    ')': GetOper:=6;
  end;
end;

Function GetPrior(dey : integer):integer;
begin
  case dey of
    1..2: GetPrior:=1;
    3..4: GetPrior:=2;
    5   : GetPrior:=0;
    6   : GetPrior:=3;
  end;
end;

Function GetNext(a:string;var pos:byte;done:boolean):string;
var ret : string;
begin
  ret := a[pos];
  inc(pos);
  if not(a[pos-1] in deyst) then
   begin
    if done then while (a[pos] <> ',') and (pos<>length(a)+1) do
       begin
        ret := ret + a[pos];
        inc(pos);
       end
    else
      while (not(a[pos] in deyst)) and (pos<>length(a)+1) do
       begin
        ret := ret + a[pos];
        inc(pos);
       end;
   end;
  if done then inc(pos);
  GetNext := ret;
end;

Procedure PUSH(i:integer;var head:ps);
var ne : ps;
begin
  New(ne);
  ne^.data := i;
  ne^.prev := head;
  head := ne;
end;

Function POP(var head:ps):integer;
var ret:integer;newhead:ps;
begin
  ret := head^.data;
  newhead := head^.prev;
  Dispose(head);
  head := newhead;
  POP := ret;
end;


Function MakePol(inp:string):string;
Var
 datas  : ps;
 opers  : ps;
 pos    : byte;
 cur    : string;
 outp   : string;
 curout : string;
 num,
 code,
 oper   : integer;
Procedure PopAll;
begin
  While (datas^.prev <>nil) and (datas^.prev^.prev <> nil) and (opers^.prev <> nil) do
   begin
    str(POP(datas),curout);
    outp := outp + curout + ',';
    str(POP(datas),curout);
    outp := outp + curout + ',';
    outp := outp+Copers[POP(opers)]+',';
    if outp[length(outp)-2] in ['(',')'] then delete(outp,length(outp)-2,2);
   end;

  While datas^.prev <> nil do
   begin
    str(POP(datas),curout);
    outp := outp + curout + ',';
   end;

  While opers^.prev <> nil do
   begin
    outp := outp+Copers[POP(opers)]+',';
    if outp[length(outp)-1] in ['(',')'] then delete(outp,length(outp)-1,2);
   end;

end;

Begin
 New(Datas);
 New(opers);
 OutP := '';
 datas^.prev := nil;
 opers^.prev := nil;
 opers^.data := 0;
 pos := 1;
 while pos <> length(inp)+1 do
   begin
     cur := GetNext(inp,pos,false);
     if cur[length(cur)] in deyst then
       begin
         oper := GetOper(cur[1]);
         if opers^.prev <> nil then
          begin
           if oper = 6 then PopAll else begin
           while (GetPrior(opers^.data) >= GetPrior(oper)) and (datas^.prev<>nil) do
             begin
               str(POP(datas),curout);
               outp := outp + curout + ',';
               if length(outp) = length(curout)+1 then
                begin
                  str(POP(datas),curout);
                  outp := outp + curout + ',';
                end;
               outp := outp+Copers[POP(opers)]+',';
               if outp[length(outp)-1] in ['(',')'] then
                 delete(outp,length(outp)-1,2);
             end;
           PUSH(oper,opers)
           end;
          end
         else
           PUSH(oper,opers);
       end
     else
       begin
         val(cur,num,code);
         PUSH(num,datas);
       end;
    end;
  PopAll;
  MakePol := outp;
end;{MakePol}
{-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-}
Procedure Calculate(polsk:string;var header : ps);
Var
   this   : string;
   pos1   : byte;
   num1,
   num2   : integer;
begin
 pos1:=1;

 While pos1 <> length(polsk)+1 do
   begin
     this := getNext(polsk,pos1,true);
     if this[length(this)] in deyst then
       begin
         num1 := POP(header);
         num2 := POP(header);
         makeD(num1,num2,this[1]);
         PUSH(num1,header);
       end
     else
      begin
        val(this,num1,num2);
        PUSH(num1,header);
      end;
   end;

end;
{--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--}
Var
  FIN   : text;
  FOUT  : text;
  inpstr: string;

begin
 Assign(FIN,'input.txt');
 Reset(FIN);
 ReadLn(FIN,InpStr);
 Close(FIN);
 Polsk := MakePol(InpStr);
{ polsk := '8,3,*,5,+,9,+,';}
 header^.prev := nil;
 Calculate(polsk,header);
 Assign(FOUT,'output.txt');
 Rewrite(Fout);
 WriteLN(FOUT,POP(header));
 Close(Fout);
end.
