var a:string; i:integer; c:boolean; begin readln(a); repeat if pos('+',a)<>0 then begin inc(i); delete(a,pos('+',a),1); end; if pos('-',a)<>0 then begin inc(i); delete(a,pos('-',a),1); end; if (pos('+',a)=0) and (pos('-',a)=0) then c:=true; until c; writeln(i); end.
Answers & Comments
var a:string;
i:integer;
c:boolean;
begin
readln(a);
repeat
if pos('+',a)<>0 then begin inc(i); delete(a,pos('+',a),1); end;
if pos('-',a)<>0 then begin inc(i); delete(a,pos('-',a),1); end;
if (pos('+',a)=0) and (pos('-',a)=0) then c:=true;
until c;
writeln(i);
end.