{$R+,S+,Q+} uses SysUtils; const R=1000;type Mas= array [0..R] of integer;var a: Mas; en,n: integer; x,y,z,q,w: char;function push(n: integer): string;begin a[en]:=n; en:=en+1; push:='ok';end;function pop(): integer;begin en:=en-1; pop:=a[en]; a[en]:=0;end;function back(): integer;begin back:=a[en-1];end;function size(): integer;begin size:=en;end;function clear(): string;begin en:=0; clear:='ok';end;function exit(): string;begin exit:='bye';end;begin en:=0; repeat read(x); if x='p' then begin read(y); if y='u' then begin read(z,q,w); readln(n); writeln(push(n)) end else begin readln(z); writeln(pop()); end; end; if x='b' then begin readln(y,z,q); writeln(back()); end; if x='s' then begin readln(y,z,q); writeln(size()); end; if x='c' then begin readln(y,z,q,w); writeln(clear()); end; if x='e' then begin readln(y,z,q); writeln(exit()); end; until x='e';end.
{$R+,S+,Q+} uses SysUtils; const R=1000;type Mas= array [0..R] of integer;var a: Mas; en,n: integer; x,y,z,q,w: char;function push(n: integer): string;begin a[en]:=n; en:=en+1; push:='ok';end;function pop(): integer;begin en:=en-1; pop:=a[en]; a[en]:=0;end;function back(): integer;begin back:=a[en-1];end;function size(): integer;begin size:=en;end;function clear(): string;begin en:=0; clear:='ok';end;function exit(): string;begin exit:='bye';end;begin en:=0; repeat read(x); if x='p' then begin read(y); if y='u' then begin read(z,q,w); readln(n); writeln(push(n)) end else begin readln(z); writeln(pop()); end; end; if x='b' then begin readln(y,z,q); writeln(back()); end; if x='s' then begin readln(y,z,q); writeln(size()); end; if x='c' then begin readln(y,z,q,w); writeln(clear()); end; if x='e' then begin readln(y,z,q); writeln(exit()); end; until x='e';end.