function CalculateAddMull(txt: string): Int64;
var num: Int64; pos: Integer; nowchar: char;
procedure next; begin if pos <= length(txt) then begin inc(pos); nowChar := txt[pos]; end else nowChar := #0; end;
procedure SkipBlank; begin while nowChar in [' '] do next; end;
procedure Abort(msg: string); begin raise Exception.Create(msg); end;
procedure addsub; forward;
procedure Getnum; begin if nowChar in ['0'..'9'] then begin num := 0; while nowChar in ['0'..'9'] do begin num := num * 10 + ord(nowChar) - ord('0'); next; end; end; end;
procedure muldiv;
var savenum: Int64; oldsym: char;
begin GetNum; while (nowChar in ['*', '/']) do
begin savenum := num; oldsym := nowChar; next; GetNum;
case oldsym of
'*': num := savenum * num;
'/': num := savenum div num;
end;
end;
end;
procedure addsub;
var savenum: Int64; oldsym: char;
begin muldiv;
while (nowChar in ['+', '-']) do begin savenum := num; oldsym := nowChar; next; muldiv;
case oldsym of
'+': num := savenum + num;
'-': num := savenum - num;
end;
end;
end;
begin
pos := 0; next; addsub; Result := num;
end;