uses crt;
var d:text; n,s:string; a,b,j,e,i,k,h,t:longint;
function uc(a,b:longint):longint;
begin
While a<>b do If a>b then a:=a-b else b:=b-a;
If a=1 then writeln(i);
end;
begin
clrscr;
assign(d,'input.pas');reset(d);
readln(d,k,h);
for i:=k to h do
begin
s:='';
str(i,n);
for j:=length(n) downto 1 do s:=s+n[j];
val(n,a,e);
val(s,b,e);
uc(a,b);
end;
close(d);
readln
end.