{$apptype console $}
Function nstr0(x, n: integer): string; //Call example writeln (nstr0 (123,5); Output 00 123
Var i: integer;
begin
Setlength (result, n);
for i:=n downto 1 do
begin
result[I]:= chr(ord(' 0 ')+x mod 10);
x:= x div 10;
End;
End;
begin
write(nstr0( 123,5));
End.