program HarshadNumbers; uses crt; var infile,outfile:text; m, n: longint; x, y, s, previous: longint; maxseq, curseq: longint; function sumdigits(num:longint):longint; var nums:string; sum:longint; x, l:integer; begin str(num,nums); sum:=0; l:=length(nums); for x:=1 to l do sum:=sum + ord(nums[x]) - 48; sumdigits:=sum; end; begin assign(infile,'DATA31.txt'); reset(infile); assign(outfile,'OUT31.txt'); rewrite(outfile); for x:=1 to 5 do begin readln(infile,m); readln(infile,n); previous:=-1; maxseq:=0; curseq:=0; for y:=m to n do begin s:=sumdigits(y); if y mod s = 0 then begin if y-1 = previous then begin inc(curseq); end else begin curseq:=1; end; previous := y; end else begin if curseq > maxseq then maxseq:=curseq; previous:=-1; curseq:=0; end; end; writeln(outfile,maxseq); end; close(infile); close(outfile); end.