Код:
var x:array[-1000000..1000000]of longint;i,m,f,j,c,l,g:longint;a,s,b,z:string;
Begin
readln(a);
read(b);
if length(b)<length(a) then
for i:=1 to length(a)-length(b) do
b:='0'+b;
if (length(a)<length(b))or(b>a)then begin
z:=a;
a:=b;b:=z;
g:=1;
end;
if length(b)<length(a) then
for i:=1 to length(a)-length(b) do
b:='0'+b;
for j:=length(a) downto 1 do
begin
val(a[j],m,f); val(b[j],c,f);
x[j]:=x[j]+(m-c);
if x[j]<0 then begin
x[j]:=x[j]+10;
x[j-1]:=x[j-1]-1;
end;
end;
b:='';
if g=1 then write('-');
for i:=1 to length(a) do
begin
str(x[i],s);
b:=b+s;
end;
while (b[1]='0')and(length(b)>1) do
delete(b,1,1);
writeln(b);
End.