You are given two integers n and k. Find k-th smallest divisor of n, or report that it doesn't exist.Divisor of n is any such natural number, that n can be divided by it without remainder.

The first line contains two integers n and k (1 ≤ n ≤ 1015, 1 ≤ k ≤ 109).

If n has less than k divisors, output -1. Otherwise, output the k-th smallest divisor of n.

NoteIn the first example, number 4 has three divisors: 1, 2 and 4. The second one is 2.In the second example, number 5 has only two divisors: 1 and 5. The third divisor doesn't exist, so the answer is -1.

var
  k,i,t,p:longint;
  n:int64;
begin
  readln(n,k);
  t:=0;
  for i:=1 to trunc(sqrt(n)) do
  if n mod i =0 then t:=t+1;
  t:=t*2;
  if trunc(sqrt(n))*trunc(sqrt(n))=n then t:=t-1;
  if k>t then writeln(-1) else
    begin
      p:=0;
      for i:=1 to trunc(sqrt(n)) do
      begin
        if n mod i=0 then p:=p+1;
        if p=k then begin writeln(i);break;end;
        if p+k=t+1 then begin writeln(n div i);break;end;
      end;
    end;
end.

var n,k,q:int64;
    i,j:longint;
    a:array[1..3000000] of int64;
begin
 read(n,k);
 j:=0;
 q:=1;
 for i:=1 to round(sqrt(n)) do
  if n mod i=0
   then begin
         if n div i<>i
          then begin
                inc(j);
                a[j]:=n div i;
               end;
         if k=q
          then begin
                write(i);
                exit;
               end;
         inc(q);
        end;
 for i:=j downto 1 do
  begin
   if k=q
    then begin
          write(a[i]);
          exit;
         end;
   inc(q);
  end;
 write('-1');
end.

var a,s,d,f,g,h,j,k,l,ii:int64;
i:longint;
z:array[1..1000000]of int64;
begin
readln(a,s);
for i:=1 to round(sqrt(a)) do
begin
     if (a mod i=0)and(i<>a div i) then
     begin
     inc(j);
     z[j]:=i;
     inc(j);
     z[j]:=a div i;
     end;
     if (a mod i=0)and(i=a div i)then
     begin
     inc(j);
     z[j]:=i;
     end;
end;
if j>=s then
begin
for i:=1 to j do
begin
if i mod 2=1 then
if i-(i div 2)=s then
writeln(z[i]);
if i mod 2=0 then
if j-(i div 2)+1=s then
writeln(z[i]);
end;
end
else writeln(-1);
end.

var
    n, k, k1: int64;
    i:longint;
    a:array[1..100000]of int64;
begin
 read(n,k);
 k1:=0;
 for i:=1 to round(sqrt(n)) do
   if n mod i =0 then
    begin
    inc(k1);
    a[k1]:=i;
    end;

 for i:=k1 downto 1 do
   if n div a[i]<>a[i] then
    begin
    inc(k1);
    a[k1]:=n div a[i];
    end;

 if k1<k
  then write(-1)
  else write(a[k]);

end.

var a:array [1..1000000] of longint;
k, j, i:longint;
n:int64;
begin
 read(n, k);
 for i:=1 to round(sqrt(n)) do
  if n mod i = 0 then
                   begin
                    inc(j);
                    a[j]:=i;
                   end;
 if n = sqr(round(sqrt(n))) then
            begin
             dec(j);
             if k > j*2+1 then write (-1) else
             if k = j+1 then write (a[j+1]) else
             if k > j+1 then write (n div a[2*j-k+2]) else
             write (a[k]);
            end else
 begin
  if k > j*2 then write (-1) else
  if (k > j) and (n=1)  then write(-1) else
  if k > j then write (n div a[2*j-k+1]) else
  write(a[k]);
 end;
end.

program codechef;
var n,k,h,j:qword; i:integer;
    d:array[1..1000000] of qword;
    c:array[1..1000000] of qword;
    kt:boolean;

function kiemtra(var a:qword):boolean;
var kt:boolean; s:qword;
begin
    kt:=false;
    s:=trunc(sqrt(a))*trunc(sqrt(a));
    if (a= s) then kt:=true;
    kiemtra:=kt;
    end;
begin
    read(n); read(k);
    h:=0;
    if n<k then write(-1) else
    begin

    for i:=1 to trunc(sqrt(n)) do
        if (n mod i) =0 then
        begin
        inc(h);
        d[h]:=i;
        c[h]:= n div i;

        if h=k then
        begin
        write (i);
        exit;
        break;
        end;

        end;
        j:=h;
        if kiemtra(n) = false then
        begin
         for i:= j   downto 1 do
         begin
            inc(h);
            d[h]:=c[i];
         end;
        end;
            if kiemtra(n) = true then
        begin
        dec(h);
         for i:= j  downto 1 do
         begin
            inc(h);
            d[h]:=c[i];
         end;
        end;

     if (k>h) then write(-1)
     else write(d[k]);

    end;

end.

Program arg;

Var n:int64;
    k:longint;
    res,i:longint;

Begin
  res:=0;
  Readln(n,k);
  For i:=1 to trunc(sqrt(n)) do begin

    if n mod i=0 then inc(res);
    if res=k then begin
      Writeln(i);
      halt;
    end;

  End;

 if trunc(sqrt(n))* trunc(sqrt(n))=n then dec(res);
  For i:=trunc(sqrt(n)) downto 1 do begin
    if n mod i=0 then inc(res);

    if res=k then begin
      Writeln(n div i);
      halt;
    end;

  End;
  Writeln(-1);

End.

program zzz;
  var
    n,k,x,i,z:int64;
    a:array[1..40000]of int64;
begin
  read(n,k);
  x:=0;
  i:=1;
  while (i<=sqrt(n)) and (k>x) do
  begin
    if (n mod i=0) then
    begin
      inc(x);
      a[x]:=i;
    end;
    inc(i);
  end;
  if x=k then writeln(i-1)
  else
  begin
    i:=x;
    while (i>=1) and(x <k) do
    begin
      if (n mod a[i]=0) and (n div a[i]<>a[i]) then inc(x);
      dec(i);
    end;
    if k=x then writeln(n div a[i+1])
    else writeln('-1');
  end;
end.

var n,k,q,j:int64;
    i:longint;
    t:array [1..100000] of int64;
begin
  readln(n,k);
  q:=0;
  j:=0;
  for i:=1 to trunc(sqrt(n)) do
    if n mod i = 0 then begin inc(q,2); if n div i = i then dec(q); end;

  if q < k then begin writeln(-1); exit; end;

  for i:=1 to trunc(sqrt(n)) do
    if n mod i = 0 then begin inc(j); t[j]:=i; t[q-j+1]:=n div i; end;

  writeln(t[k]);

end.

 var k,i:longint;
     n:qword;
begin
 readln(n,k);
 for i:=1 to round(sqrt(n)) do begin
   if n mod i = 0 then
     dec(k);
   if k=0 then begin
     writeln(i);
     break;
   end;
 end;
 if k>0 then begin
   if round(sqrt(n))=sqrt(n) then
     inc(k);
   for i:=round(sqrt(n)) downto 1 do begin
     if n mod i = 0 then
       dec(k);
     if k=0 then begin
       writeln(n div i);
       break;
     end;
   end;
   if k>0 then
     writeln(-1);
 end;
end.

var kol,kol2,n,k:int64;
 a:array[1..100000]of int64;
 i:longint;

begin

readln(n,k);
for i:=1 to round(sqrt(n)) do
 begin
 if n mod i = 0 then
  begin
   inc(kol);
   a[kol]:=i;
  end;
 end;
 kol2:=kol;
 for i:=kol2 downto 1 do
 begin
  if n div a[i] <> a[i] then
   begin
   inc(kol);
   a[kol]:=n div a[i];
   end;
 end;
 if kol<k then
  writeln(-1)
 else
 writeln(a[k]);

end.

var a,n,c,d,sum,k:int64;
i:longint;
begin
    readln( a,k );
    n:=1;
    for i:=1 to round(sqrt(a)) do
    begin
       c:=a mod n;
       d:=a div n;
       if c = 0
       then begin
          inc(sum);
          if sum=k
          then begin
           writeln(n);
           exit;
          end;

       end;
       inc( n );
    end;
    n:=round(sqrt(a));
    for i:=round(sqrt(a)) downto 1 do
    begin
       c:=a mod n;
       d:=a div n;
       if c = 0
       then begin
         if n <> d
         then begin
          inc(sum);
          if sum=k
          then begin
           writeln(d);
           exit;
          end;
         end;

       end;
       dec(n);
    end;
writeln(-1);

end.

var q,s,n,k,b:int64;
i:longint;
a:array[1..1000000] of int64;
begin
readln(n,k);
for i:=1 to round(sqrt(n)) do
if n mod i = 0 then
begin
     inc(s);
     b:=n div i;
     if b<>i then inc(s);
end;
if s<k then
begin
     writeln(-1);
     halt;
end;
for i:=1 to round(sqrt(n)) do
if n mod i=0 then
begin
     inc(q); a[q]:=i; b:=n div i;
     if b<>i then a[s-q+1]:=n div i;
end;
writeln(a[k]);
end.

  var N , K : Int64;
      i : LongInt;
begin
  readLn ( N , K ) ;

  for i := 1 to 100000000 do
  begin

    if ( N mod I = 0 ) then
    begin
      dec ( K ) ;

      if ( K = 0 ) then
      begin
        writeLn ( i ) ;
        halt();
      end;
    end;

  end;

  for i := 100000000 downto 1 do
  begin
    if ( N mod I = 0 ) and ( N div I > 100000000 ) then
    begin
      dec ( k ) ;
      if ( k = 0 ) then
      begin
        writeLn ( N div I ) ;
        halt();
      end;
    end;
  end;

  writeLn ( -1 ) ;

end.

var
n,k,x:int64;
i,j,p,m:longint;
a:array[1..100000] of int64;
 begin
readln(n,k);  i:=0;

   for i:=1 to trunc(sqrt(n)) do begin
   if (n mod i=0) then
    begin
    j:=j+1;
    if j=k then
           begin
            writeln(i);
            halt;
           end ;
     a[j]:=n div i;
    end;  end;

if trunc(sqrt(n))=sqrt(n) then   begin p:=2*j-1;j:=j-1; end  else p:=2*j;
if  (k>p) then begin writeln(-1); halt; end else
begin
 for i:=1 to j div 2 do
 begin
 x:=a[i];
 a[i]:=a[j-i+1];
 a[j-i+1]:=x
 end;
 if trunc(sqrt(n))=sqrt(n) then write(a[k-j-1]) else write(a[k-j]);
end;
  end.

var n,k,max,i,summ:int64; mass:array[0..100000] of int64;

procedure qSort(l,r:longint);
var i,j:longint;
     w,q:int64;
begin
   i := l; j := r;
   q := mass[(l+r) div 2];
   repeat
     while (mass[i] < q) do inc(i);
     while (q < mass[j]) do dec(j);
     if (i <= j) then
     begin
       w:=mass[i]; mass[i]:=mass[j]; mass[j]:=w;
       inc(i); dec(j);
     end;
   until (i > j);
   if (l < j) then qSort(l,j);
   if (i < r) then qSort(i,r);
end;

begin

read(n,k);

max:=trunc(sqrt(n));

i:=1;

while(i<=max) do
begin
    if(n mod i = 0) then
    begin
        inc(summ);
        mass[summ]:=i;
        if(i <> n div i) then
        begin
            inc(summ);
            mass[summ]:=n div i;
        end;
    end;
    inc(i);
end;

if(n=k) and (n=1) then
begin
    write(1);
    exit;
end else

if(n=1) then
begin
    write('-1');
    exit;
end;

if(summ<k) then
begin
    write('-1');
end else
begin
    qSort(1, summ);
    writeln(mass[k]);
end;

end.

var q,kol,n,k,a:int64;
i:longint;
b:array[1..1000000] of int64;
begin
readln(n,k);
for i:=1 to round(sqrt(n)) do
if n mod i = 0 then begin inc(kol); a:=n div i; if a<>i then inc(kol); end;
if kol<k then begin writeln(-1); halt; end;
for i:=1 to round(sqrt(n)) do
if n mod i=0 then begin inc(q); b[q]:=i; a:=n div i; if a<>i then b[kol-q+1]:=n div i; end;
writeln(b[k]);
end.

var n, k, res: int64;
    i: LongInt;

begin

  readln (n, k);
  res := -1;

  for i := 1 to 100000000 do
  begin
    if (n mod i = 0) then
      dec (k);
	if (k = 0) then
	begin
	   res := i;
	   break;
	end;
  end;

  for i := 100000000 downto 1 do
  begin
    if (n mod i = 0) and (n div i > 100000000) then
	begin
	  dec (k);
	  if (k = 0) then
	  begin
        res := n div i;
        break;
      end;
	end;
  end;

  writeln (res);

end.

var a:array[1..1000000] of int64;
    n,k,del,k2:int64;
    i:longint;
begin
read(n,del);
k:=0;
for i:=1 to round(sqrt(n)) do
  begin
     if n mod i = 0 then
       begin
         inc(k);
         a[k]:=i;
       end;
  end;
k2:=k;
for i:=k2 downto 1 do
  begin
     if n div a[i] <> a[i] then
        begin
          inc(k);
          a[k]:=n div a[i];
        end;
  end;
if k<del then write(-1) else write(a[del]);
end.

var a:array [1..31622780] of int64;
	k:longint;
	f,n:int64;

procedure qs(l,r:longint);
	var i,j,ind:longint;
		x,w:int64;
begin
	i:=l;
	j:=r;
	randomize;
	ind:=l+random(r-l+1);
	x:=a[ind];
	repeat
		while a[i]<x do inc(i);
		while a[j]>x do dec(j);
		if i <= j then	begin
							w:=a[i];
							a[i]:=a[j];
							a[j]:=w;
							inc(i);
							dec(j);
						end;
	until i>j;
	if l<j then qs(l,j);
	if i<r then qs(i,r);
end;

procedure del(x:int64);
	var i:longint;
		l,r:int64;
begin
	for i:=1 to round(sqrt(x)) do
		begin
			if x mod i = 0 then begin
									l:=i;
									r:=x div i;
									if l <> r then	begin
							                            inc(k);
														a[k]:=l;
														inc(k);
														a[k]:=r;
													end
											   else begin
											   			inc(k);
											   			a[k]:=l;
											   		end;
								end;
		end;
end;

begin
	k:=0;
	readln(f,n);
	del(f);
//	writeln(k);
	if n > k then begin writeln('-1'); halt; end;
	qs(1,k);
//	for h:=1 to k do
//		write(a[h],' '); writeln;

	writeln(a[n]);
end.

program Matfey;
var
x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,j,qb,qe,K,E,N,G,Y,R : int64;
i : longint;
c1,c2,c3,c4,c5,c6,c7,c8,c9,c10 : char;
s1,s2,s3,s4,s5,s6,s7,s8,s9,s10 : string;
r1,r2,r3,r4,r5,r6,r7,r8,r9,r10 : real;
i1,i2,i3,i4,i5 : integer;
{q : array[1..3000000,1..3] of longint;}
a1 : array[1..1000000{,-160..160}] of int64;
begin
{assign(input,'DIVSUM.IN'); reset(input);
assign(output,'DIVSUM.OUT'); rewrite(output);}
readln(x1,x2);

r1:=sqrt(x1);
x8:=trunc(r1);
x3:=1;

for i:=1 to x8 do
begin

if (x1 mod i)=0 then
begin
 x5:=x5+1;
 if x3=x2 then
 begin
 writeln(i);
 exit;
 end;

 if i<>(x1 div i) then
 begin

 a1[x3]:=x1 div i;
 x3:=x3+1;
 end;

end;

end;

{for i:=1 to 5 do
begin
writeln(a1[i]);
end;            }
x4:=1;
x3:=x3-1;
for i:=x3 downto 1 do
begin
if (x4=(x2-x5)) and (a1[i]<>0) then begin writeln(a1[i]); exit; end;
x4:=x4+1;
end;
writeln(-1);
{close(input); close(output);}
end.

type tlist=array[1..1000000] of int64;
var i,len:longint;
n,k:int64;
a:tlist;
procedure qsort(var a : tlist;max:longint);

    procedure sort(l,r: longint);
      var
         i,j: longint;
         x,y:int64;
      begin
         i:=l;
         j:=r;
         x:=a[(l+r) div 2];
         repeat
           while a[i]<x do
            inc(i);
           while x<a[j] do
            dec(j);
           if not(i>j) then
             begin
                y:=a[i];
                a[i]:=a[j];
                a[j]:=y;
                inc(i);
                j:=j-1;
             end;
         until i>j;
         if l<j then
           sort(l,j);
         if i<r then
           sort(i,r);
      end;

    begin
       sort(1,max);
    end;
begin
//writeln;
//write(high(longint));exit;
read(n,k);
//len:=2;
//a[1]:=1;a[2]:=n;
for i:=1 to trunc(Sqrt(n)) do begin
        if n mod i=0 then begin
                inc(len);
                a[len]:=i;
                if i<>n div i then begin
                        inc(len);
                        a[len]:=n div i;
                end;
        end;
end;
if k>len then begin
        write(-1);
        exit;
end;
qsort(a,len);
write(a[k]);
end.

var n:int64;
   i:longint;
   a:array[0..1000000] of int64;
   k,kol:longint;

   procedure sort(l,r: longint);
      var
         i,j:longint;
         x,y:int64;
      begin
         i:=l;
         j:=r;
         x:=a[l+random(r-l)];
         repeat
           while a[i]<x do
            inc(i);
           while x<a[j] do
            dec(j);
           if not(i>j) then
             begin
                y:=a[i];
                a[i]:=a[j];
                a[j]:=y;
                inc(i);
                j:=j-1;
             end;
         until i>j;
         if l<j then
           sort(l,j);
         if i<r then
           sort(i,r);
      end;

 begin

  read(n,k);
   for i:=1 to trunc(sqrt(n)) do
    if( n mod i=0) then
     begin
      inc(kol);
      a[kol]:=i;
      inc(kol);
      a[kol]:=n div i;
     end;

     if(a[kol] = a[kol-1]) then dec(kol);

     sort(1,kol);

     if(kol<k) then write(-1) else writeln(a[k]);

 end.

program bt;
const 	fi=''; fo='';
var 	f:text;
	n,k:int64;
	a:array[1..1000000] of longint;
//
procedure doctep;
begin
	assign(f,fi); reset(f);
	readln(f,n,k);
	close(f);
end;
//
function kt(x:int64):boolean;
var 	l:int64;
begin
	kt:=false; l:=trunc(sqrt(x));
	if l*l = x then kt:=true;
end;
//
procedure ghitep;
var 	i,j,l,tmp,d:longint;
begin
	d:=0;
	assign(f,fo); rewrite(f);
        if n=1 then
                begin
                        if k>1 then writeln(f,-1);
                        if k=1 then writeln(f,1);
                end
        else
        begin
	if kt(n)=false then
	begin
	for i:=1 to trunc(sqrt(n)) do
		if n mod i=0 then
		begin
			inc(d);
			a[d]:=i;
		end;
	if 2*d<k then writeln(f,-1)
	else
	begin
		if d>=k then writeln(f,a[k]);
		if d<k then writeln(f, n/a[2*d-k+1] :0:0);
	end;
	end
	else
		begin
			for i:=1 to trunc(sqrt(n)) do
			if n mod i=0 then
			begin
				inc(d);
				a[d]:=i;
			end;
		if 2*d<=k then writeln(f,-1)
		else
		begin
			if d>=k then writeln(f,a[k]);
			if d<k then writeln(f, n/a[2*d-k] :0:0);
		end;
        end;
		end;
	close(f);
end;
//
Begin
	doctep;
	ghitep;
end.

program adada;
var     a,b,k,i,j,m:longint;
        n:int64;
begin
        readln(n,k);
        a:=0;
        for i:=1 to trunc(sqrt(n)) do
        if n mod i=0 then
        begin
                inc(a);
                if a=k then break;
        end;
        if a=k then
        begin
                writeln(i);
                exit;
        end;
        if sqr(trunc(sqrt(n)))=n then m:=1
        else m:=0;
        for i:=trunc(sqrt(n))-m downto 1 do
                if n mod i=0 then
                begin
                        inc(a);
                        if a=k then break;
                end;
        if a=k then writeln(n div i)
        else writeln(-1);
end.

var o,k:longint; a:array[1..1000000] of int64;
    n,t,i:int64;
    Procedure QuickSort(L,R : longint);
  var
    i, j : longint;t,x:int64;
  begin
    i := L; j := R; x:=a[L+random(R-L+1)];
    repeat
      while a[i] < x do i := i + 1;
      while a[j] > x do j := j - 1;
      if i<=j
         then begin
                t := a[i]; a[i] := a[j]; a[j] := t;
                i := i + 1; j := j - 1;
              end;
    until i>j;
    if L<j then QuickSort(L,j);
    if i<R then QuickSort(i,R);
  end;
 begin
 readln(n,k);
 t:=trunc(sqrt(n));
 i:=1;
 while i<=t do begin
 if n mod i = 0 then begin
                     inc(o);
                     a[o]:=i;
                     if i*i<>n then begin
                     inc(o);
                     a[o]:=n div i end;
                     end;
 inc(i)
 end;
     quicksort(1,o);
     if k>o then writeln(-1)
     else writeln(a[k]);
     end.

var
  a, b, c, d, i, k, k1: int64;
  ar, ar1: array [1..200000] of int64;

begin
  readln(a, b);
  k := 0;
  k1 := 0;
  i := 1;
  while i * i <= a do begin
    if a mod i = 0 then begin
      inc(k);
      ar[k] := i;
      if a div i <> i then begin
        inc(k1);
        ar1[k1] := a div i;
      end;
    end;
    inc(i);
  end;
  if b > k + k1 then begin
    writeln(-1);
    halt();
  end;
  if b <= k then begin
    writeln(ar[b]);
    halt();
  end;
  writeln(ar1[k1 - (b - k) + 1]);
end.

program tmp15;
 var
  n:qword;
  x:extended;
  flag:boolean;
  nx,i,k,t,all:longint;
 procedure away(x:qword);
  begin
   writeln(x);halt;
  end;
 begin
  readln(n,k);t:=0;
  nx:=trunc(sqrt(n));
  for i:=1 to nx do
   begin
    if n mod i=0 then
     begin
      inc(t);
      if t=k then away(i);
     end;
   end;
  all:=2*t;
  x:=sqrt(n);
  if x-nx<=1E-8 then dec(all);
  if k>all then
   begin
    writeln(-1);halt;
   end;
  k:=all-k+1;
  t:=0;
  for i:=1 to nx do
   begin
    if n mod i=0 then
     begin
       inc(t);
       if t=k then away(n div i);
     end;
   end;
 end.

var i,k,t,w,n:int64;
begin
{assign(input,'input.txt');
assign(output,'output.txt');
reset(input);
rewrite(output); }
read(n,k);
i:=1;
t:=0;
while i*i<=n do
  begin
    if n mod i=0 then
      if i*i=n then t:=t+1 else t:=t+2;
    i:=i+1;
  end;
if k>t then write(-1)
  else begin
    w:=0;
    if k>t div 2 then
      begin
        k:=t-k+1;
        w:=1;
      end;
    i:=0;
    while k>0 do
      begin
        i:=i+1;
        if n mod i=0 then k:=k-1;
      end;
    if w=0 then write(i)
      else write(n div i);
  end;
end.

var
  i: longint;
  m, kk, k1, l, r: int64;

begin
  readln(m, kk);
  for i := 1 to round(sqrt(m)) do
    if (m mod i = 0) then begin
      if (m div i) <> i then k1 := k1 + 2
      else k1 := k1 + 1;
    end;
  if k1 < kk then begin
    writeln(-1);
    exit;
  end;
  l := 1;r := k1;
  for i := 1 to round(sqrt(m)) do
    if (m mod i = 0) then begin
      if l = kk then begin
        writeln(i);
        break;
      end;
      if r = kk then begin
        writeln(m div i);
        break;
      end;
      l := l + 1;
      r := r - 1;
    end;

end.

var n,k,kol,kol2:int64;
    i:longint;
    a:array[1..100000]of int64;
begin
 read(n,k);
 for i:=1 to round(sqrt(n)) do
  begin
   if n mod i =0
    then begin
          inc(kol);
          a[kol]:=i;
         end;
  end;
 kol2:=kol;
 for i:=kol2 downto 1 do
  begin

   if n div a[i]<>a[i]
    then begin inc(kol); a[kol]:=n div a[i]; end;
  end;

 if kol<k
  then write(-1)
  else write(a[k]);

end.

{$IFDEF ONLINE_JUDGE}
{$R-,Q-,S-,I-}
{$OPTIMIZATION LEVEL2}
{$INLINE ON}
{$ENDIF}

uses math;

procedure mofile;
begin
        {$IFDEF ONLINE_JUDGE}
        assign(input,'');
        reset(input);
        assign(output,'');
        rewrite(output);
        {$ELSE}
        assign(input,'checking.inp');
        reset(input);
        assign(output,'');
        rewrite(output);
        {$ENDIF}
end;

procedure dongfile;
begin
        close(input);
        close(output);
end;

const
        maxc=1000000000+69;
        modulo=1000000000+7;

type
        re=record
                x,y:longint;
        end;

var
        n,k,m:int64;
        dem,cnt:longint;
        a:array[0..1000000] of int64;

procedure xuli;
var
        i:longint;
begin
        readln(n,k);
        dem:=1;
        for i:=1 to trunc(sqrt(n)) do
        if n mod i=0 then
        begin
                inc(dem);
                if n div i<>i then inc(dem);
        end;
        m:=dem;

        cnt:=0;
        for i:=1 to trunc(sqrt(n)) do
        if n mod i=0 then
        begin
                inc(cnt);
                a[cnt]:=i;
                if n div i<>i then
                begin
                        dec(dem);
                        a[dem]:=n div i;
                end;
        end;

        if k>=m then writeln(-1) else writeln(a[k]);
end;

begin
        mofile;
        xuli;
        dongfile;
end.

var n,k,count,result,i,j:int64;
	A,A1:array[1..30000] of int64;
Begin
	Read(n,k);
	result:=-1;
	count:=0;
	j:=0;
	i:=1;
	While (i<=trunc(sqrt(n))) do
		Begin
			If n mod i=0 then
				Begin
					inc(count);
					//Write(i,' ');
					If (n div i<>i) then
						Begin
							inc(j);
							A[j]:=n div i;
						End;

					If (count=k) then
						Begin
							Write(i);
							halt;
						End;
				End;
			inc(i);
		End;

	A1[j]:=n;
	dec(k,count);
	i:=j;
	While(i>1) do
		Begin
			A1[j-i+1]:=A[i];
			dec(i);
		End;

	If (j>=k) then
		result:=A1[k];

	Write(result);
End.

var n,k,count,result,i,j:int64;
	A,A1:array[1..50000] of int64;
Begin
	Read(n,k);
	result:=-1;
	count:=0;
	j:=0;
	i:=1;
	While (i<=trunc(sqrt(n))) do
		Begin
			If n mod i=0 then
				Begin
					inc(count);
					//Write(i,' ');
					If (n div i<>i) then
						Begin
							inc(j);
							A[j]:=n div i;
						End;

					If (count=k) then
						Begin
							Write(i);
							halt;
						End;
				End;
			inc(i);
		End;

	A1[j]:=n;
	dec(k,count);
	i:=j;
	While(i>1) do
		Begin
			A1[j-i+1]:=A[i];
			dec(i);
		End;

	If (j>=k) then
		result:=A1[k];

	Write(result);
End.

var n,k,count,result,i,j:int64;
	A,A1:array[1..100000] of int64;
Begin
	Read(n,k);
	result:=-1;
	count:=0;
	j:=0;
	i:=1;
	While (i<=trunc(sqrt(n))) do
		Begin
			If n mod i=0 then
				Begin
					inc(count);
					//Write(i,' ');
					If (n div i<>i) then
						Begin
							inc(j);
							A[j]:=n div i;
						End;

					If (count=k) then
						Begin
							Write(i);
							halt;
						End;
				End;
			inc(i);
		End;

	A1[j]:=n;
	dec(k,count);
	i:=j;
	While(i>1) do
		Begin
			A1[j-i+1]:=A[i];
			dec(i);
		End;

	If (j>=k) then
		result:=A1[k];

	Write(result);
End.

var n,k,count,result,i,j:int64;
	A,A1:array[1..1000000] of int64;
Begin
	Read(n,k);
	result:=-1;
	count:=0;
	j:=0;
	i:=1;
	While (i<=trunc(sqrt(n))) do
		Begin
			If n mod i=0 then
				Begin
					inc(count);
					//Write(i,' ');
					If (n div i<>i) then
						Begin
							inc(j);
							A[j]:=n div i;
						End;

					If (count=k) then
						Begin
							Write(i);
							halt;
						End;
				End;
			inc(i);
		End;

	A1[j]:=n;
	dec(k,count);
	i:=j;
	While(i>1) do
		Begin
			A1[j-i+1]:=A[i];
			dec(i);
		End;

	If (j>=k) then
		result:=A1[k];

	Write(result);
End.

var n,k,count,result,i,j:int64;
	A,A1:array[1..10000000] of int64;
Begin
	Read(n,k);
	result:=-1;
	count:=0;
	j:=0;
	i:=1;
	While (i<=trunc(sqrt(n))) do
		Begin
			If n mod i=0 then
				Begin
					inc(count);
					//Write(i,' ');
					If (n div i<>i) then
						Begin
							inc(j);
							A[j]:=n div i;
						End;

					If (count=k) then
						Begin
							Write(i);
							halt;
						End;
				End;
			inc(i);
		End;

	A1[j]:=n;
	dec(k,count);
	i:=j;
	While(i>1) do
		Begin
			A1[j-i+1]:=A[i];
			dec(i);
		End;

	If (j>=k) then
		result:=A1[k];

	Write(result);
End.

var
 n,sc,k,r,sqx,l,ans:int64;
 i,j:longint;
begin
 readln(n,k);
 sqx:=trunc(sqrt(n));
 for i:=1 to  sqx do if n mod i =0 then
 begin
 inc(sc);
 if i<>n div i  then inc(sc);
 end;
 if sc<k then begin writeln(-1); halt; end;

 l:=0;
 r:=sc+1;
 for i:=1 to sqx  do   if n mod i=0 then
 begin
  inc(l);
  if l=k then begin writeln(i); halt; end;
  if i<>n div i then dec(r);
  if r=k then begin writeln(n div i); halt; end;
 end;
end.

var
    n, k, k1: int64;
    i:longint;
    a:array[1..100000]of int64;
begin
 read(n,k);
 k1:=0;
 for i:=1 to round(sqrt(n)) do
   if n mod i =0 then
    begin
    inc(k1);
    a[k1]:=i;
    end;

 for i:=k1 downto 1 do
   if n div a[i]<>a[i] then
    begin
    inc(k1);
    a[k1]:=n div a[i];
    end;

 if k1<k
  then write(-1)
  else write(a[k]);

end.

                                                  const eps=1e-10;
          besk=8000000000000000000; label 1,3,2,44;
    type mas=array[-10000..550000+1] of int64; integer=longint;
    var i1,j1,mask,stepp,h,n2,i,j,k,l,step,k1,w,mesto:longint;
    ss,ss1:string;
    kol,dx,dy,ll,rr,sum,m,start,finish,time,p3,p4,jj,qqq,ii,tt,pmax,pmax2,qq,p1,p2,ot,ott,hh,pos0,pos1,pos2,pp,mm,maxot,mnog,tmax,summax,n,nn,kk,modul,t0,t1,n1,t2,q,t,p:int64; flag1:boolean;
     num, urovpoint,predok,urov,summ,place,str,a2,b2,last,left,right,zz,z1,sum1,sum0,d0,d1,ccc,c,d,lnew,rnew,a,b:mas; flag2,flag:boolean;  pl:longint;
     jmax,maxx, gr,grr,ener,dob,aa,bb,cc,dist,tt3,tt1,tt2,ugg,aa1,aa2,r,ug:int64;
      marked,zan:array[-10..1000000] of boolean;
      zzz,a1,b1,strok:array[-10..550000] of int64;
      stroka:array[-1000..1000000] of char;
      vv,ot1,otmax,v:extended;
      sp,sss:array[-10..2000000] of string;
      newpole,dd,pole:array[-100..1210,-1..1210] of int64;
      dchet,dnech,poschet,posnechet:array[-10..290000,-1..30] of int64;
      pos:int64;
      ch:char;
      flagg1:boolean;
      ymax,ymin,xmax,xmin,znach,z,nomer,newplace,newstr,s,next,prev,xx,yy,aold,x,y:array[-100000..2000002] of int64;
      ddd:array[-10..5010,-10..5010] of int64;
     function srav(i,j:longint):boolean;
      begin if (a[i]<a[j])or(a[i]=a[j])and(a1[i]<a1[j])or(a[i]=a[j])and(a1[i]=a1[j])and(a2[i]<a2[j])  then
      srav:=true else srav:=false; end;

    procedure sl (k,l,m:integer);  {k- dlina, l,m - nachalo dvuh blokov}
    begin
    i:=l;j:=m; flag:=true; step:=0;while flag do begin
    if (srav(i,j)) then begin begin b[l+step]:=a[i];b1[l+step]:=a1[i];b2[l+step]:=a2[i];end;
    inc(step);inc(i);
    {writeln('step=',step,' i=',i);} end;
    if (not srav(i,j)) then begin begin b[l+step]:=a[j];b1[l+step]:=a1[j];b2[l+step]:=a2[j];end;
    inc(step);inc(j);end;
    if  ((i>=l+k) or (j>=m+k)) then flag:=false;
    end;
    if(i>=l+k) then repeat b[l+step]:=a[j];b1[l+step]:=a1[j];b2[l+step]:=a2[j];inc(step);inc(j);until (j>=m+k);
    if(j>=m+k) then repeat b[l+step]:=a[i];b1[l+step]:=a1[i];b2[l+step]:=a2[i];inc(step);inc(i);until (i>=l+k);
    end;
    procedure sort(var c:mas);

    begin

    k:=1; repeat
    l:=1;m:=k+l; repeat sl(k,l,m); l:=l+2*k;m:=m+2*k; until (l>=n); k:=k*2;
    for i:=1 to n do begin a[i]:=b[i];a1[i]:=b1[i];a2[i]:=b2[i]; end;
    until (k>=n);

    end;

    function min (a,b:int64):int64;begin min:=b;if a<b then min:=a;  end;
    function max (a,b:int64):int64;begin max:=b;if a>b then max:=a;  end;

    function phi(a,b:double):double; label 222;var p:double;
    begin
      if (a>0)and (b>=0) then begin p:=arctan(b/a);goto 222; end;
      if (a<0) then begin p:=pi+arctan(b/a);goto 222; end;
      if (a>0)and (b<0) then begin p:=2*pi+arctan(b/a);goto 222; end;
      if (a=0)and (b>0) then begin p:=pi/2;goto 222; end;
      if (a=0)and (b<0) then begin p:=3*pi/2;goto 222; end;
      222: phi:=p;
    end;

    function nod(a,b:int64):int64; var p,t:int64;
    begin
      a:=abs(a); b:=abs(b);
      if (a>0)and(b>0) then
       begin while (b>0) do begin t:=a mod b;a:=b;b:=t;    end;
        p:=a;
       end else if a=0 then p:=b else p:=a;
    nod:=p;
    end;

    function nok(a,b:int64):int64;
    begin  nok:=(a*b) div nod(a,b);  end;

       function degg(a:int64;k:int64):int64; var p:int64;
    begin
     if k<=0 then degg:=1 else if odd(k) then degg:=(degg(a,k-1)*a) mod modul  else
       begin  p:=degg(a,k div 2); degg:=(p*p) mod modul;    end;

    end;

    procedure udal(ii:longint);
    begin  next[prev[ii]]:=next[ii];prev[next[ii]]:=prev[ii];  end;

    function nomerr(gr:int64):int64;

    var ot,aa,bb,cc:int64; fl:boolean;
    begin
      aa:=1; bb:=p;  cc:=aa; fl:=false;
      while abs(aa-bb)>1 do
        begin
           cc:=(aa+bb) shr 1;
           if y[cc]<=gr then aa:=cc else bb:=cc;

        end;
      { writeln(' cc= ',cc);
      } cc:=min(cc+3,p+1);
       repeat dec(cc) until y[cc]<=gr;
       if y[cc]=gr then fl:=true else fl:=false;
       { if fl then nomerr:=a1[cc] else nomerr:=-1000;}
       nomerr:=cc;
    end;

     function vhodit(t:int64):boolean;
    var sum,ii,jj,p:int64;  ans:boolean;
    begin
       p:=t;
       for i:=1 to t do a[i]:=x[i];
        n:=1;
        repeat n:=n*2 until n>=p;
             for i:=p+1 to n+2 do a[i]:=besk;
            sort(a);
        { for i:=1 to p do write(a[i],' '); writeln;
         }
         sum:=0;
        if not odd(t) then
         for i:=1 to t div 2 do sum:=sum+a[2*i] else
         for i:=1 to (t+1) div 2 do sum:=sum+a[2*i-1];
        { writeln('sum= ',sum);
         }
     ans:=sum<=hh;
    vhodit:=ans;
    end;

    function prost(pp:longint):boolean;
    var i,j,t:longint; tt:extended; fl:boolean;
    begin
      tt:=pp;
      tt:=sqrt(tt);
      fl:=true;
      for i:=2 to round(tt) do if pp mod i=0 then  fl:=false;

     prost:=fl;

    end;

     function inside(p1,p2:longint):boolean;
    var pp,rr:int64; fl:boolean;
    begin
      rr:=(xx[p1]-xx[p2])* (xx[p1]-xx[p2])+(yy[p1]-yy[p2])* (yy[p1]-yy[p2]);

      inside:=(rr<=(zz[p1]+zz[p2])* (zz[p1]+zz[p2]))and(zz[p1]<zz[p2]);
    end;

    begin

     {  assign (input,'D:\Projects\input.txt');reset(input);
       assign (output,'D:\Projects\output.txt'); rewrite(output);
      }

        read(n,p);
        v:=n;
        v:=sqrt(v);
        for i:=1 to round(v) do
          if n mod i=0  then begin  ii:=i; if ii*ii<>n then pp:=pp+2 else inc(pp);   end;

          t:=0;
        for i:=1 to round(v) do
          if n mod i=0  then
          begin  ii:=i; if ii*ii<>n then
            begin inc(t); a[t]:=i; a[pp+1-t]:=n div i end else
            begin inc(t); a[t]:=i;    end;
          end;

         if p>pp then write(-1) else
         for i:=p to p do write(a[i],' '); writeln;

     1: close (output);
         end.

var i,k:longint;
    n,j:int64;
    a:array[1..1000000] of int64;

procedure quicksort(L,H : integer);
var
    i,j,pivot,y : int64;
begin
    i := L;
    j := H;
    pivot := a[random(H - L + 1) + L];

    repeat
        while a[i] < pivot do inc(i);
        while a[j] > pivot do dec(j);
        if i <= j then
        begin
        y:=a[i];
        a[i]:=a[j];
        a[j]:=y;
        inc(i);
        dec(j);
        end;
    until i > j;
    if L < j then quicksort(L,j);
    if i < H then quicksort(i,H);
end;

begin
read(n,k);
for i:=1 to round(sqrt(n)) do
if n mod i=0 then begin
                  inc(j); a[j]:=i;
                  if n div i<>i then begin
                                     inc(j);
                                     a[j]:=n div i;
                                     end;
                  end;
quicksort(1,j);
if k>j then write(-1) else write(a[k]);
end.

var n:int64;
k,i,num:longint;
a:Array[0..3000000] of int64;

    procedure sort(l,r: longint);
      var
         i,j: longint;x,y:int64;
      begin
         i:=l;
         j:=r;
         x:=a[(l+r)>>1];
         repeat
           while a[i]<x do
            inc(i);
           while x<a[j] do
            dec(j);
           if not(i>j) then
             begin
                y:=a[i];
                a[i]:=a[j];
                a[j]:=y;
                inc(i);
                j:=j-1;
             end;
         until i>j;
         if l<j then
           sort(l,j);
         if i<r then
           sort(i,r);
      end;

begin
  readln(n,k);
  for i:=1 to trunc(sqrt(n)) do
  if n mod i=0 then
  begin
    inc(num);
    a[num]:=i;
    inc(num);
    a[num]:=n div i;
    if i=n div i then dec(num);
  end;
  if k>num then begin write(-1);halt;end;
  sort(1,num);
  write(a[k]);
end.

program z1;
var i,j,l,m,uk,un,mark:longint; Z,Q:array[0..100000] of int64;  n,d,a,b,c,old,k:int64;

Procedure sort(l,r:longint);
var i,j:longint; x,y:int64;
begin
i:=l; j:=r; x:=Z[(l+r)>>1];
repeat
while Z[i]<x do inc(i);
while Z[j]>x do dec(j);
if not(i>j) then begin y:=Z[i]; Z[i]:=Z[j]; Z[j]:=y; inc(i); dec(j); end;
until (i>j);
if i<r then sort(i,r);
if l<j then sort(l,j);
end;

begin
//assign(input,'d:\input.txt'); reset(input);
//assign(output,'d:\output.txt'); rewrite(output);
readln(n,k);
for i:=1 to round(sqrt(n)) do
 begin
 if n mod i=0 then begin inc(a); Z[a]:=i; if n div i<>i then begin inc(a); Z[a]:=n div i; end; end;
 end;
sort(1,a);
if k>a then writeln(-1) else
writeln(Z[k]);
//writeln(un); for i:=1 to un do write(Z[i],' ');
end.

var q,kol,n,k,a:int64;
i:longint;
b:array[1..1000000] of int64;
begin
readln(n,k);
for i:=1 to round(sqrt(n)) do
  if n mod i = 0 then
    begin
    inc(kol);
    a:=n div i;
    if a<>i then inc(kol);
    end;
  if kol<k then
    begin
    writeln(-1);
    halt;
    end;
for i:=1 to round(sqrt(n)) do
  if n mod i=0 then
    begin
      inc(q);
      b[q]:=i;
      a:=n div i;
      if a<>i then b[kol-q+1]:=n div i;
    end;
writeln(b[k]);
end.

var n,k,kol,kol1:int64;
i:longint;
a:array[1..100000]of int64;
begin
read(n,k);
i:=1;
for i:=1 to round(sqrt(n)) do
        if n mod i = 0 then
                begin
                inc(kol);
                if n div i <> i then  inc(kol);
                end;
if kol>=k then
begin
i:=1;
for i:=1 to round(sqrt(n)) do
        if n mod i = 0 then
                begin
                inc(kol1);
                a[kol1]:=i;
                a[kol-kol1+1]:=n div i;
                end;
write(a[k]);
end else write(-1);
end.

const fi='762A.inp'; fo='762A.out';
var n,k,tong:int64;
    i:longint;
begin
 readln(n,k);
 For i:=1 to trunc(sqrt(n)) do
    if n mod i=0 then
       begin
          dec(k);
          if k=0 then
             begin
                writeln(i);
                halt;
             end;
       end;
 tong:=trunc(sqrt(n));
 if sqrt(n)=trunc(sqrt(n)) then dec(tong);
 For i:=tong downto 1 do
    begin
       if n mod i=0 then
          begin
             dec(k);
             if k=0 then
                begin
                   writeln(n div i);
                   halt;
                end;
          end;
    end;
 writeln(-1);
end.

Program z1;
var
    n:int64;
    p:array[1..1000000] of int64;
    m,t,k:integer;
    i:integer;

begin
    read(n,k);
    for i:=1 to trunc(sqrt(n)) do begin
        if n mod i = 0 then begin
            inc(m);
            p[m]:=i;
        end;
    end;
    t:=m;
    if trunc(sqrt(n))-sqrt(n)=0 then dec(m);
    for i:=m downto 1 do begin
        inc(t);
        p[t]:=n div p[i];
    end;
    if k>t then write(-1) else write(p[k]);
end.

var
  i,j:longint;
  n,k:int64;
  x:array[1..20000000]of int64;
procedure sort(l,r:int64);
var i,e,j,t:int64;
begin
  i:=l;
  j:=r;
  e:=x[l+random(r-l+1)];
  while i<=j do
  begin
    while e>x[i] do inc(i);
    while e<x[j] do dec(j);
    if i<=j then
    begin
    t:=x[i];x[i]:=x[j];x[j]:=t;
    inc(i);
    dec(j);
    end;
  end;
  if i<r then sort(i,r);
  if j>l then sort(l,j);
end;
begin
  read(n,k);
  j:=0;
  for i:=1 to trunc(sqrt(n)) do
  if n mod i=0 then
  begin
  inc(j);x[j]:=n div i;
  if n div i<>i then begin
  inc(j);x[j]:=i;end;
  end;

  if k>j then begin writeln(-1);halt;end;

  sort(1,j);

//  for i:=1 to j do
//  write(x[i],' ');

  writeln(x[k]);
end.

var
   n:int64;
   m,k,i,j:longint;
   a:array[1..1000000] of int64;
begin
   readln (n,k);
   m:=round(sqrt(n));
   i:=1;
   j:=0;
   while (j<k)and(i<=m) do
   begin
      if n mod i=0 then
         begin inc(j);
         a[j]:=i;
         end;
      inc(i);
   end;
   i:=j;
   if j=k then writeln (a[k]) else
      begin
         inc(j);
         a[j]:=n div a[i];
         if a[i]=a[j] then dec(j);
         dec(i);
         while  (i>0)and(j<k) do
         begin
            inc(j);
            a[j]:=n div a[i];
            dec(i);
         end;
         if j=k then writeln (a[k]) else writeln (-1);
      end;
end.

var i:longint;
n,k,k1,l,r:int64;
   begin
     readln(n,k);
     for i:=1 to round(sqrt(n)) do
           if (n mod i=0)then begin
                                if (n div i)<>i then k1:=k1+2
                                else k1:=k1+1;
                                end;
         if k1<k then begin
                        writeln(-1);
                          exit;
                          end;
         l:=1;r:=k1;
       for i:=1 to round(sqrt(n)) do
         if (n mod i=0) then begin
                                if l=k then begin
                                        writeln(i);
                                        break;
                                        end;
                                   if r=k then begin
                                        writeln(n div i);
                                        break;
                                        end;
                                     l:=l+1;
                                     r:=r-1;
                                  end;

     end.

var n,c,k,r,l,ans:int64;i,j:longint;
begin
 readln(n,k);
 for i:=1 to  round(sqrt(n)) do
 if n mod i =0 then
 begin
 c:=c+1;
 if i<>n div i then
 c:=c+1;
 end;
 if c<k then
 begin
 writeln(-1);
 halt;
 end;
 l:=0;
 r:=c+1;
 for i:=1 to round(sqrt(n)) do
 if n mod i=0 then
 begin
 l:=l+1;
 if l=k then begin
 writeln(i);
 halt;
 end;
 if i<>n div i then
 dec(r);
 if r=k then begin
 writeln(n div i);
 halt;
 end;
 end;
end.

{$mode objfpc}

const
 InputFile='';
 OutputFile='';

var
 fi,fo          :Text;
 n,k,DCount,P   :Int64;
 i              :LongInt;
 u              :Array[0..1000500] of Int64;

procedure OpenF;
begin
 Assign(fi,InputFile);
 Reset(fi);
 Assign(fo,OutputFile);
 Rewrite(fo);
end;

procedure Input;
begin
 Read(fi,n,k);
end;

procedure Process;
begin
 FillChar(u,sizeof(u),0);
 P:=1;
 For i:=1 to trunc(sqrt(n)) do
  If n mod i = 0 then
   begin
    DCount:=DCount+2;
    u[P]:=i;
    inc(P);
   end;
 Dec(P);
 If sqrt(n)=trunc(sqrt(n)) then dec(DCount);
end;

procedure Output;
begin
 If k>DCount then
  begin
   Write(fo,-1);
   Exit;
  end;
 If k<=DCount div 2 then write(fo,u[k]) else write(fo,n div u[DCount+1-k]);
end;

procedure CloseF;
begin
 Close(fi);
 Close(fo);
end;

begin
 OpenF;
 Input;
 Process;
 Output;
 CloseF;
end.

var f1,f2 : text;
    a : array[1..10000000] of int64;
    kt : boolean;
    n,k,t,d : int64;
    i : longint;

begin
assign(f1,'') ; reset(f1);
assign(f2,'') ; rewrite(f2);
readln(f1,n,k);
kt := false;
for i := 1 to trunc(sqrt(n)) do
        if n mod i = 0 then
                begin
                inc(d);
                a[d] := i;
                end;
if trunc(sqrt(n)) * trunc(sqrt(n)) = n then kt := true;
t := d*2;
if kt = true then dec(t);
if k > t then
        begin
        write(f2,-1);
        close(f1);
        close(f2);
        halt;
        end;
for i := 1 to d do
        if k = i then
                begin
                write(f2,a[i]);
                close(f1);
                close(f2);
                halt
                end
           else if t-i+1 = k then
                        begin
                        write(f2,n div a[i]);
                        close(f1);
                        close(f2);
                        halt
                        end;
close(f1);
close(f2);
end.

const   fi='';
        fo='';
var     f,g             :text;
        n,k                     :int64;
        a                       :array[0..100002] of int64;
procedure nhap;
begin
        assign(f,fi);reset(f);
        assign(g,fo);rewrite(g);
        readln(f,n,k);
        close(f);
end;

procedure main;
var   dem,i,u     :longint;
begin
        dem:=0;
        for i:=1 to trunc(sqrt(n)) do
                if n mod i =0 then
                        begin
                                inc(dem);a[dem]:=i;
                        end;
        u:=ord(sqr(trunc(sqrt(n)))=n);
        if dem*2-u<k then begin writeln(g,-1);exit;end;

        if dem>=k then writeln(g,a[k])
        else writeln(g,n div a[dem-(k-dem)+1-u]);
end;

BEGIN
        Nhap;
        main;
        close(g);
END.

var i,e,k:longint;
a:array[0..100000] of int64;
n,s:int64;
    procedure sort(l,r: longint);
      var
         i,j,x,y: int64;
      begin
         i:=l;
         j:=r;
         x:=a[(l+r) div 2];
         repeat
           while a[i]<x do
            inc(i);
           while x<a[j] do
            dec(j);
           if not(i>j) then
             begin
                y:=a[i];
                a[i]:=a[j];
                a[j]:=y;
                inc(i);
                j:=j-1;
             end;
         until i>j;
         if l<j then
           sort(l,j);
         if i<r then
           sort(i,r);
      end;
begin
   {assign(input,'input.txt');
   assign(output,'output.txt');
   reset(input);
   rewrite(output);}
   read(n,k);
   s:=trunc(sqrt(n));
   for i:=1 to s do
   if n mod i=0 then
   begin
      inc(e,2);
      a[e-1]:=i;
      a[e]:=n div i;
      if (i=s)and(s*s=n) then dec(e);
   end;
   sort(1,e);
   if e>=k then write(a[k]) else write(-1);
end.

var n,k,kol:int64;
    a:array[1..1000000] of int64;
    i:longint;
begin
read(n,k);
for i:=1 to round(sqrt(n)) do
 if n mod i=0 then begin
  inc(kol);
  a[kol]:=i;
 end;

if kol>=k then write(a[k])
          else begin
               if n div a[kol]=a[kol] then inc(k);
               if k>kol*2 then begin write(-1); halt; end;
               k:=k-kol;
               write(n div a[kol-k+1]);
               end;
end.

var
 n,k,m,t,stn: int64;
 i: longint;
 st: array [0..320000] of int64;
begin
 readln(n,k);
 m:=trunc(sqrt(n));

 if (n = 1) and (k > 1) then begin writeln(-1); halt; end;

 for i:=1 to m do if n mod i = 0 then
 begin
  inc(t);
  st[t]:=n div i;
  if t = k then begin writeln(i); halt; end;
 end;

 stn:=t;
 for i:=stn downto 1 do if sqrt(n) <> st[i] then
 begin
  inc(t);
  if t = k then begin writeln(st[i]); halt; end;
 end;

 writeln(-1);
end.

program O_O;
type
	ll=longint;
	bo=boolean;
	arr=array[0..10000000] of int64;
var
	i,k:ll;
	n,j,jj:int64;
	a:arr;
begin
	readln(n,k);
	j:=0;
	for i:=1 to trunc(sqrt(n)+0.5) do
	begin
		if n mod i=0 then
		begin
			inc(j);
			a[j]:=i;
		end;
	end;
	jj:=j;
	for i:=jj downto 1 do
	begin
		if n div a[i]<>a[i] then
		begin
			inc(j);
			a[j]:=n div a[i];
		end;
	end;
	if k>j then writeln(-1)
	else 	writeln(a[k]);
end.

var a:array [1..1000000] of longint;
k, j, i:longint;
n:int64;
begin
 read(n, k);
 for i:=1 to round(sqrt(n)) do
  if n mod i = 0 then
                   begin
                    inc(j);
                    a[j]:=i;
                   end;
 if k > j*2 then write (-1) else
 if (k > j) and (n=1)  then write(-1) else
 if k > j then write (n div a[2*j-k+1]) else
 write(a[k]);
end.

var a:array [1..1000000] of longint;
k, j, i:longint;
n:int64;
begin
 read(n, k);
 for i:=1 to round(sqrt(n)) do
  if n mod i = 0 then
                   begin
                    inc(j);
                    a[j]:=i;
                   end;
 if n = sqr(round(sqrt(n))) then
  for i:=j-1 downto 1 do
   a[2*j-i] := n div a[i]
 else
  for i:=j downto 1 do
   a[2*j-i+1] := n div a[i];
 if (k>2*j) or (a[k]=0) then write (-1) else
 write(a[k]);
end.

var a:array [1..1000000] of longint;
k, j, i:longint;
n:int64;
begin
 read(n, k);
 for i:=1 to round(sqrt(n)) do
  if n mod i = 0 then
                   begin
                    inc(j);
                    a[j]:=i;
                   end;
 if k > j*2 then write (-1) else
 if k > j   then write (n div a[k-j]) else
 write(a[k]);
end.

var a:array [1..1000000] of longint;
k, j, i:longint;
n:int64;
begin
 read(n, k);
 for i:=1 to round(sqrt(n)) do
  if n mod i = 0 then
                   begin
                    inc(j);
                    a[j]:=i;
                   end;
 if k > j*2 then write (-1) else
 if k > j   then write (n div a[2*j-k+1]) else
 write(a[k]);
end.

program codechef;
var n,k,h,i:integer;
    d:array[1..1000000] of integer;
    c:array[1..1000000] of integer;
    kt:boolean;
begin
    read(n); read(k);
    h:=0;

    kt:=true;
    for i:=1 to trunc(sqrt(n)) do
        if (n mod i) =0 then
        begin
        inc(h);
        d[h]:=i;
        c[h]:= n div i;
        end;

    if (k <= trunc(sqrt(n))) then write(d[k]);
     if (k >  trunc(sqrt(n))) and (k<=h) then write(c[k-h+1]);
     if (k>h) then write(-1);
	(* your code goes here *)
end.

program codechef;
var n,k,h,i:integer;
    d:array[1..1000000] of integer;
    c:array[1..1000000] of integer;
    kt:boolean;
begin
    read(n); read(k);
    h:=0;
    if n<k then write(-1) else
    begin

    for i:=1 to trunc(sqrt(n)) do
        if (n mod i) =0 then
        begin
        inc(h);
        d[h]:=i;
        c[h]:= n div i;

        end;
    if (k<=trunc(sqrt(n))) then write(d[k]);
     if (k>trunc(sqrt(n))) then write(c[k-h]);
    if (k>h*2) then write(-1);
    end;

end.

program codechef;
var n,k,h,j:qword; i:integer;
    d:array[1..1000000] of qword;
    c:array[1..1000000] of qword;
    kt:boolean;
begin
    read(n); read(k);
    h:=0;
    if n<k then write(-1) else
    begin

    for i:=1 to trunc(sqrt(n)) do
        if (n mod i) =0 then
        begin
        inc(h);
        d[h]:=i;
        c[h]:= n div i;
        if h=k then
        begin
        write (i);
        exit;
        break;
        end;

        end;
        j:=h;

     if (k>h*2) then write(-1)
     else
     begin
    if (k<=trunc(sqrt(n))) then write(d[k]);
     if (k>trunc(sqrt(n))) then write(c[k-h]);
     end;
   ;
    end;
	(* your code goes here *)
end.

program codechef;
var n,k,h,i:integer;
    kt:boolean;
begin
    read(n); read(k);
    h:=0;
    kt:=true;
    for i:=1 to n do
    begin
        if(n mod i)=0 then
        begin
            inc(h);
            if h=k then
            begin
            write(i);
            kt:=false;
            exit;
            end;
         end;

    end;
    if kt=true then write(1);
	(* your code goes here *)
end.

Program arg;

Var n:int64;
    k:longint;
    res,i:longint;

Begin
  res:=0;
  Readln(n,k);
  For i:=1 to trunc(sqrt(n)) do begin
    if n mod i=0 then inc(res);
    if res=k then begin
      Writeln(i);
      halt;
    end;

  End;
 // Writeln(trunc(sqrt(n)));
 if i*i=n then dec(res);
  For i:=trunc(sqrt(n)) downto 1 do begin
    if n mod i=0 then inc(res);
    if res=k then begin
      Writeln(n div i);
      halt;
    end;

  End;
  Writeln(-1);

End.

program zzz;
  var
    n,k,x,i:int64;
begin
  read(n,k);
  x:=0;
  i:=1;
  while (i<=sqrt(n)) and (k>x) do
  begin
    if (n mod i=0) then inc(x);
    inc(i);
  end;
  if x=k then
  writeln(i-1)
  else if x=k-1 then writeln(n)
       else if (x=k-2) and(n mod(n div 2)=0) then writeln(n div 2)
            else writeln('-1');
end.

program zzz;
  var
    n,k,x,i,z:int64;
    a:array[1..40000]of int64;
begin
  read(n,k);
  x:=0;
  i:=1;
  while (i<=sqrt(n)) and (k>x) do
  begin
    if (n mod i=0) then
    begin
      inc(x);
      a[x]:=i;
    end;
    inc(i);
  end;
  if x=k then writeln(i-1)
  else
  begin
    i:=x;
    while (i>=1) and(x <k) do
    begin
      if n mod a[i]=0 then inc(x);
      dec(i);
    end;
    if k=x then writeln(n div a[i+1])
    else writeln('-1');
  end;
end.

program zzz;
  var
    n,k,x,i:int64;
begin
  read(n,k);
  x:=0;
  i:=1;
  while (i<=sqrt(n)) and (k>x) do
  begin
    if (n mod i=0) then inc(x);
    inc(i);
  end;
  if x=k then
  writeln(i-1)
  else if x=k-1 then writeln(n)
       else if x=k-2 then writeln(n div 2)
            else writeln('-1');
end.

var j,m,i,k:integer;
n:int64;
all:array[1..1000]of longint;

begin

readln(n,k);
m:=0;
j:=0;
for i:=1 to n do
 if (n mod i)=0 then
  begin
   m:=m+1;
   j:=j+1;
   all[j]:=i;
  end;
all[j+1]:=n;
m:=m+1;
 if m<k then
  writeln(-1)
 else
  writeln(all[k]);
end.

var j,m,i,k,n:longint;
all:array[1..1000]of longint;

begin

readln(n,k);

for i:=1 to round(sqrt(n)) do
 if (n mod i)=0 then
  begin
   m:=m+1;
   j:=j+1;
   all[j]:=i;
  end;
all[j+1]:=n;
m:=m+1;
 if m<k then
  writeln(-1)
 else
  writeln(all[k]);
end.

var j,m,i,k:integer;
n:int64;
all:array[1..1000]of longint;

begin

readln(n,k);
m:=0;
j:=0;
for i:=1 to (n div 2) do
 if (n mod i)=0 then
  begin
   m:=m+1;
   j:=j+1;
   all[j]:=i;
  end;
all[j+1]:=n;
m:=m+1;
 if m<k then
  writeln(-1)
 else
  writeln(all[k]);
end.

var j,m,i,k,n:longint;
all:array[1..1000]of longint;

begin

readln(n,k);

for i:=1 to round(sqrt(n)) do
 if (n mod i)=0 then
  begin
   m:=m+1;
   j:=j+1;
   all[j]:=i;
  end;
 if m<k then
  writeln(-1)
 else
  writeln(all[k]);
end.

var kol,kol2,n,k:int64;
 a:array[1..100000]of integer;
 i:longint;

begin

readln(n,k);
for i:=1 to round(sqrt(n)) do
 begin
 if n mod i = 0 then
  begin
   inc(kol);
   a[kol]:=i;
  end;
 end;
 kol2:=kol;
 for i:=kol2 downto 1 do
 begin
  if n div a[i] <> a[i] then
   begin
   inc(kol);
   a[kol]:=n div a[i];
   end;
 end;
 if kol<k then
  writeln(-1)
 else
 writeln(a[k]);

end.

var j,m,i,k,n:integer;
all:array[1..100]of int64;

begin

readln(n,k);

for i:=1 to n-1 do
 if (n mod i)=0 then
  begin
   m:=m+1;
   j:=j+1;
   all[j]:=i;
  end;
 if m<k then
  writeln(-1)
 else
  writeln(all[k]);
end.

var n,k,i,c,ind:longint;
begin
read(n,k);
if k=1 then writeln('1');
if n mod 2=0 then begin
i:=1;
c:=0;
repeat
if (n mod i)=0 then begin c:=c+1; ind:=i; end;
i:=i+1;
until (c=k)or(i=n)or(n-c<k-c);
if c=k then writeln(ind) else writeln('-1');
end;
if n mod 2<>0 then begin
i:=1;
c:=0;
repeat
if (n mod i)=0 then begin c:=c+1; ind:=i; end;
i:=i+2;
until (c=k)or(i=n)or(n-c<k-c);
if c=k then writeln(ind) else writeln('-1');
end;
end.

var
n,k,x:int64;
i,j,p,m:longint;
a:array[1..10000000] of longint;
 begin
readln(n,k);  i:=0;

   for i:=1 to trunc(sqrt(n)) do begin
   if (n mod i=0) then
    begin
    j:=j+1;
    if j=k then
           begin
            writeln(i);
            halt;
           end ;
     a[j]:=n div i;
    end;  end;

if trunc(sqrt(n))=sqrt(n) then   begin p:=2*j-1;j:=j-1; end  else p:=2*j;
if  (k>p) then begin writeln(-1); halt; end else
begin
 for i:=1 to j div 2 do
 begin
 x:=a[i];
 a[i]:=a[j-i+1];
 a[j-i+1]:=x
 end;
 if trunc(sqrt(n))=sqrt(n) then write(a[k-j-1]) else write(a[k-j]);
end;
  end.

var
n,k:int64;
i,j,p:longint;
a:array[1..10000000] of int64;
 procedure sort(l,r: longint);
      var
         i,j,x,y: longint;
      begin
         i:=l;
         j:=r;
         x:=a[(l+r) div 2];
         repeat
           while a[i]< x do
            inc(i);
           while x<a[j] do
            dec(j);
           if not(i>j) then
             begin
                y:=a[i];
                a[i]:=a[j];
                a[j]:=y;
                inc(i);
                j:=j-1;
             end;
         until i>j;
         if l<j then
           sort(l,j);
         if i<r then
           sort(i,r);
      end;
begin
readln(n,k);  i:=0;
for i:=1 to round(sqrt(n)) do begin
if (n mod i=0) then
begin
j:=j+1;
a[j]:=i;
if i*i<>n
then begin
j:=j+1;
a[j]:=n div i;
     end;
end;
end;

  p:=j;
  sort(1,p);
  for i:=1 to p do

  if  (k>p) then writeln(-1) else writeln(a[k]);
  end.

var
n,k:int64;
i,j,p:longint;
a:array[1..10000000] of int64;
 procedure sort(l,r: longint);
      var
         i,j,x,y: longint;
      begin
         i:=l;
         j:=r;
         x:=a[(l+r) div 2];
         repeat
           while a[i]< x do
            inc(i);
           while x<a[j] do
            dec(j);
           if not(i>j) then
             begin
                y:=a[i];
                a[i]:=a[j];
                a[j]:=y;
                inc(i);
                j:=j-1;
             end;
         until i>j;
         if l<j then
           sort(l,j);
         if i<r then
           sort(i,r);
      end;
begin
readln(n,k);  i:=0;
for i:=1 to round(sqrt(n)) do begin
if (n mod i=0) then
begin
j:=j+1;
a[j]:=i;
if i*i<>n
then begin
j:=j+1;
a[j]:=n div i;
     end;
end;
end;

  p:=j;
  sort(1,p);

  if  (k>p) then writeln(-1) else writeln(a[k]);
  end.

var
n,k,d:int64;
i,j,p:longint;
a:array[1..10000000] of longint;
 procedure sort(l,r: longint);
      var
         i,j,x,y: longint;
      begin
         i:=l;
         j:=r;
         x:=a[(l+r) div 2];
         repeat
           while a[i]< x do
            inc(i);
           while x<a[j] do
            dec(j);
           if not(i>j) then
             begin
                y:=a[i];
                a[i]:=a[j];
                a[j]:=y;
                inc(i);
                j:=j-1;
             end;
         until i>j;
         if l<j then
           sort(l,j);
         if i<r then
           sort(i,r);
      end;
begin
readln(n,k);  i:=0;
for i:=1 to round(sqrt(n)) do begin
if (n mod i=0) then
begin
j:=j+1;
a[j]:=i;
if sqrt(n)<>round(sqrt(n))
then begin
j:=j+1;
a[j]:=n div i;
     end;
end;
end;

  p:=j;
  sort(1,p);
  if  (k>p) then writeln(-1) else writeln(a[k]);
  end.

var
n,k:int64;
i,j,p:longint;
a:array[1..10000000] of int64;
 procedure sort(l,r: longint);
      var
         i,j,x,y: longint;
      begin
         i:=l;
         j:=r;
         x:=a[(l+r) div 2];
         repeat
           while a[i]< x do
            inc(i);
           while x<a[j] do
            dec(j);
           if not(i>j) then
             begin
                y:=a[i];
                a[i]:=a[j];
                a[j]:=y;
                inc(i);
                j:=j-1;
             end;
         until i>j;
         if l<j then
           sort(l,j);
         if i<r then
           sort(i,r);
      end;
begin
readln(n,k);  i:=0;
for i:=1 to round(sqrt(n)) do begin
if (n mod i=0) then
begin
j:=j+1;
a[j]:=i;
if sqrt(n)<>round(sqrt(n))
then begin
j:=j+1;
a[j]:=n div i;
     end;
end;
end;

  p:=j;
  sort(1,p);
  if  (k>p) then writeln(-1) else writeln(a[k]);
  end.

var n,k,max,i,summ:int64; mass:array[0..100000] of int64;

procedure qSort(l,r:longint);
var i,j:longint;
     w,q:int64;
begin
   i := l; j := r;
   q := mass[(l+r) div 2];
   repeat
     while (mass[i] < q) do inc(i);
     while (q < mass[j]) do dec(j);
     if (i <= j) then
     begin
       w:=mass[i]; mass[i]:=mass[j]; mass[j]:=w;
       inc(i); dec(j);
     end;
   until (i > j);
   if (l < j) then qSort(l,j);
   if (i < r) then qSort(i,r);
end;

begin

read(n,k);

max:=trunc(sqrt(n));

i:=1;

while(i<=max) do
begin
    if(n mod i = 0) then
    begin
        inc(summ);
        mass[summ]:=i;
        inc(summ);
        mass[summ]:=n div i;
    end;
    inc(i);
end;

if(n=k) and (n=1) then
begin
    write(1);
    exit;
end else

if(n=1) then
begin
    write('-1');
    exit;
end;

if(summ<k) then
begin
    write('-1');
end else
begin
    qSort(1, summ);
    writeln(mass[k]);
end;

end.

var n,k:int64; max,i,summ:integer;
begin

read(n,k);

max:=n div 2;

for i:=1 to max do
begin
    if(n mod i = 0) then
    begin
        inc(summ);
        if(summ = k) then
        begin
            write(i);
        end;
    end;
end;

if(summ<k) then
begin
    write('-1');
end;

end.

var n,k:int64; max,i,summ:integer;
begin

read(n,k);

max:=n div 2;

for i:=1 to max do
begin
    if(n mod i = 0) then
    begin
        inc(summ);
        if(summ = k) then
        begin
            write(i);
        end;
    end;
end;

if(n=k) and (n=1) then
begin
    write(1);
    exit;
end;

if(summ<k) then
begin
    write('-1');
end;

end.

var n,k,max,i,summ:int64; mass:array[0..100000] of int64;

procedure qSort(l,r:longint);
var i,j:longint;
     w,q:int64;
begin
   i := l; j := r;
   q := mass[(l+r) div 2];
   repeat
     while (mass[i] < q) do inc(i);
     while (q < mass[j]) do dec(j);
     if (i <= j) then
     begin
       w:=mass[i]; mass[i]:=mass[j]; mass[j]:=w;
       inc(i); dec(j);
     end;
   until (i > j);
   if (l < j) then qSort(l,j);
   if (i < r) then qSort(i,r);
end;

begin

read(n,k);

max:=trunc(sqrt(n));

i:=1;

while(i<=max) do
begin
    if(n mod i = 0) then
    begin
        inc(summ);
        mass[summ]:=i;
        inc(summ);
        mass[summ]:=n div i;
    end;
    inc(i);
end;

if(n=k) and (n=1) then
begin
    write(1);
    exit;
end;

if(summ<k) then
begin
    write('-1');
end else
begin
    qSort(1, summ);
    writeln(mass[k]);
end;

end.

var n,k,max,i,summ:int64; mass:array[0..100000] of int64;

procedure qSort(l,r:longint);
var i,j:longint;
     w,q:int64;
begin
   i := l; j := r;
   q := mass[(l+r) div 2];
   repeat
     while (mass[i] < q) do inc(i);
     while (q < mass[j]) do dec(j);
     if (i <= j) then
     begin
       w:=mass[i]; mass[i]:=mass[j]; mass[j]:=w;
       inc(i); dec(j);
     end;
   until (i > j);
   if (l < j) then qSort(l,j);
   if (i < r) then qSort(i,r);
end;

begin

read(n,k);

max:=trunc(sqrt(n));

i:=1;

while(i<=max) do
begin
    if(n mod i = 0) then
    begin
        inc(summ);
        mass[summ]:=i;
        inc(summ);
        mass[summ]:=n div i;
    end;
    inc(i);
end;

if(n=k) and (n=1) then
begin
    write(1);
    exit;
end;

if(summ*2<k) then
begin
    write('-1');
end else
begin
    qSort(1, summ);
    writeln(mass[k]);
end;

end.

var n,k,max,i,summ:int64; mass:array[0..100000] of int64;

procedure qSort(l,r:longint);
var i,j:longint;
     w,q:int64;
begin
   i := l; j := r;
   q := mass[(l+r) div 2];
   repeat
     while (mass[i] < q) do inc(i);
     while (q < mass[j]) do dec(j);
     if (i <= j) then
     begin
       w:=mass[i]; mass[i]:=mass[j]; mass[j]:=w;
       inc(i); dec(j);
     end;
   until (i > j);
   if (l < j) then qSort(l,j);
   if (i < r) then qSort(i,r);
end;

begin

read(n,k);

max:=trunc(sqrt(n));

i:=1;

while(i<=max) do
begin
    if(n mod i = 0) then
    begin
        inc(summ);
        mass[summ]:=i;
        inc(summ);
        mass[summ]:=n div i;
    end;
    inc(i);
end;

if(n=k) and (n=1) then
begin
    write(1);
    exit;
end else

if(n=1) then
begin
    write('-1');
end;

if(summ<k) then
begin
    write('-1');
end else
begin
    qSort(1, summ);
    writeln(mass[k]);
end;

end.

var n, k: int64;
    c, i: LongInt;
	res: LongInt;

begin

  readln (n, k);
  c := 0;
  res := -1;

  for i := 1 to 40000000 do
  begin
    if (n mod i = 0) then
	  inc (c);
	if (c = k) then
	begin
	  res := i;
	  break;
	end;
  end;

  writeln (res);

end.

var k1,k,n,i,f:int64;
begin
read(n,k);
k1:=0; i:=1;
while i<=n do
  begin
    if k=k1 then
       begin
          write(i-1);
          exit;
       end else
     if n mod i = 0 then inc(k1);
    inc(i);
  end;
if k>k1 then write(-1);
end.

var a:array[1..1000000] of int64;
    n,k,del,k2:int64;
    i:longint;
begin
read(n,del);
k:=0;
for i:=1 to round(sqrt(n)) do
  begin
     if n mod i = 0 then
       begin
         inc(k);
         a[k]:=i;
       end;
  end;
k2:=k;
for i:=k2-1 downto 1 do
  begin
     if n mod a[i] = 0 then
        begin
          inc(k);
          a[k]:=n div a[i];
        end;
  end;
if k<del then write(-1) else
  if k=del then write(a[del-1]) else
    write(a[del]);
end.

var a:array[1..1000000] of int64;
    n,k,del,k2:int64;
    i:longint;
begin
read(n,del);
k:=0;
for i:=1 to round(sqrt(n)) do
  begin
     if n mod i = 0 then
       begin
         inc(k);
         a[k]:=i;
       end;
  end;
k2:=k;
for i:=k2 downto 1 do
  begin
     if n mod a[i] = 0 then
        begin
          inc(k);
          a[k]:=n div a[i];
        end;
  end;
if k<del then write(-1) else write(a[del]);
end.

var a:array[1..1000000] of int64;
    n,k,del,k2:int64;
    i:longint;
begin
read(n,del);
k:=0;
for i:=1 to round(sqrt(n)) do
  begin
     if n mod i = 0 then
       begin
         inc(k);
         a[k]:=i;
       end;
  end;
k2:=k;
for i:=k2-1 downto 1 do
  begin
     if n mod a[i] = 0 then
        begin
          inc(k);
          a[k]:=n div a[i];
        end;
  end;
if k<del then write(-1) else write(a[del]);
end.

var a:array [1..31622780] of int64;
	h,k:longint;
	f,n:int64;

procedure qs(l,r:longint);
	var i,j,w,x,ind:longint;
begin
	i:=l;
	j:=r;
	randomize;
	ind:=l+random(r-l+1);
	x:=a[ind];
	repeat
		while a[i]<x do inc(i);
		while a[j]>x do dec(j);
		if i <= j then	begin
							w:=a[i];
							a[i]:=a[j];
							a[j]:=w;
							inc(i);
							dec(j);
						end;
	until i>j;
	if l<j then qs(l,j);
	if i<r then qs(i,r);
end;

procedure del(x:longint);
	var i,l,r:longint;
begin
	for i:=1 to round(sqrt(x)) do
		begin
			if x mod i = 0 then begin
									l:=i;
									r:=x div i;
									if l <> r then	begin
							                            inc(k);
														a[k]:=l;
														inc(k);
														a[k]:=r;
													end
											   else begin
											   			inc(k);
											   			a[k]:=l;
											   		end;
								end;
		end;
end;

begin
	k:=0;
	readln(f,n);
	del(f);
//	writeln(k);
	if n > k then begin writeln('-1'); halt; end;
	qs(1,k);
//	for h:=1 to k do
//		write(a[h],' '); writeln;

	writeln(a[n]);
end.

program Matfey;
var
x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,j,qb,qe,K,E,N,G,Y,R : int64;
i : longint;
c1,c2,c3,c4,c5,c6,c7,c8,c9,c10 : char;
s1,s2,s3,s4,s5,s6,s7,s8,s9,s10 : string;
r1,r2,r3,r4,r5,r6,r7,r8,r9,r10 : real;
i1,i2,i3,i4,i5 : integer;
{q : array[1..3000000,1..3] of longint;}
a1 : array[1..1000000{,-160..160}] of int64;
begin
{assign(input,'DIVSUM.IN'); reset(input);
assign(output,'DIVSUM.OUT'); rewrite(output);}
readln(x1,x2);

r1:=sqrt(x1);
x8:=trunc(r1);
x3:=1;

for i:=1 to x8 do
begin

if (x1 mod i)=0 then
begin
 if x3=x2 then
 begin
 writeln(i);
 exit;
 end;

 if i<>(x1 div i) then
 begin
 a1[x3]:=x1 div i;
 x3:=x3+1;
 end;

end;

end;

for i:=x3 downto 1 do
begin
if (i=(x2-x3+1)) and (a1[i]<>0) then begin writeln(a1[i]); exit; end;
end;
writeln(-1);
{close(input); close(output);}
end.

program Matfey;
var
x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,j,qb,qe,K,E,N,G,Y,R : int64;
i : longint;
c1,c2,c3,c4,c5,c6,c7,c8,c9,c10 : char;
s1,s2,s3,s4,s5,s6,s7,s8,s9,s10 : string;
r1,r2,r3,r4,r5,r6,r7,r8,r9,r10 : real;
i1,i2,i3,i4,i5 : integer;
{q : array[1..3000000,1..3] of longint;}
a1 : array[1..1000000{,-160..160}] of int64;
begin
{assign(input,'DIVSUM.IN'); reset(input);
assign(output,'DIVSUM.OUT'); rewrite(output);}
readln(x1,x2);

r1:=sqrt(x1);
x8:=trunc(r1);
x3:=1;

for i:=1 to x8 do
begin

if (x1 mod i)=0 then
begin
 if x3=x2 then
 begin
 writeln(i);
 exit;
 end;

 if i<>(x1 div i) then
 begin

 a1[x3]:=x1 div i;
 x3:=x3+1;
 end;

end;

end;
{
for i:=1 to 5 do
begin
writeln(a1[i]);
end;         }
x4:=1;
x3:=x3-1;
for i:=x3 downto 1 do
begin
if (x4=(x2-x3)) and (a1[i]<>0) then begin writeln(a1[i]); exit; end;
x4:=x4+1;
end;
writeln(-1);
{close(input); close(output);}
end.

program Matfey;
var
x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,j,qb,qe,K,E,N,G,Y,R : int64;
i : longint;
c1,c2,c3,c4,c5,c6,c7,c8,c9,c10 : char;
s1,s2,s3,s4,s5,s6,s7,s8,s9,s10 : string;
r1,r2,r3,r4,r5,r6,r7,r8,r9,r10 : real;
i1,i2,i3,i4,i5 : integer;
{q : array[1..3000000,1..3] of longint;}
a1,a2 : array[1..10000000{,-160..160}] of longint;
begin
{assign(input,'DIVSUM.IN'); reset(input);
assign(output,'DIVSUM.OUT'); rewrite(output);}
readln(x1,x2);

r1:=sqrt(x1);
x8:=trunc(r1);
x3:=1;
for i:=1 to x8 do
begin

if (x1 mod i)=0 then
begin
if x3=x2 then
begin

writeln(i);
exit;

end;
if i<>(x1 div i) then
begin
a1[x3]:=x1 div i;
x3:=x3+1;
end;
end;

end;

for i:=x3 downto 1 do
begin
if (i=(x2-x3+1)) and (a1[i]<>0) then begin writeln(a1[i]); exit; end;
end;
writeln(-1);
{close(input); close(output);}
end.

program bt;
const 	fi=''; fo='';
var 	f:text;
	n,k:int64;
	a:array[1..1000000] of longint;
//
procedure doctep;
begin
	assign(f,fi); reset(f);
	readln(f,n,k);
	close(f);
end;
//
procedure ghitep;
var 	i,j,l,tmp,d:longint;
begin
	d:=0;
	assign(f,fo); rewrite(f);
        if n=1 then
                begin
                        if k>1 then writeln(f,-1);
                        if k=1 then writeln(f,1);
                end
        else
        begin
	for i:=1 to trunc(sqrt(n)) do
		if n mod i=0 then
		begin
			inc(d);
			a[d]:=i;
		end;
	if 2*d<k then writeln(f,-1)
	else
	begin
		if d>=k then writeln(f,a[k]);
		if d<k then writeln(f, n/a[2*d-k+1] :0:0);
	end;
        end;
	close(f);
end;
//
Begin
	doctep;
	ghitep;
end.

program bt;
const 	fi=''; fo='';
var 	f:text;
	n,k:longint;
//
procedure doctep;
begin
	assign(f,fi); reset(f);
	readln(f,n,k);
	close(f);
end;
//
procedure ghitep;
var 	i,d,tmp:longint;
begin
	assign(f,fo); rewrite(f);
        d:=0;  i:=1;
           while (d<=k) and (i<=n div 2) do
		begin
			if n mod i=0 then
                        begin
                                inc(d);
			        tmp:=i; writeln(f,i);
                        end;
                        inc(i);
		end;
        if d<k then
        begin
                d:=d+1;
                tmp:=n;
        end;
	if d<k then writeln(f,-1)
        //if d=k then wirteln(f,n);
        else writeln(f,tmp);
	close(f);
end;
//
Begin
	doctep;
	ghitep;
end.

program bt;
const 	fi=''; fo='';
var 	f:text;
	n,k:int64;
	a:array[1..1000000] of longint;
//
procedure doctep;
begin
	assign(f,fi); reset(f);
	readln(f,n,k);
	close(f);
end;
//
procedure ghitep;
var 	i,j,l,tmp,d:longint;
begin
	d:=0;
	assign(f,fo); rewrite(f);
	for i:=1 to trunc(sqrt(n)) do
		if n mod i=0 then
		begin
			inc(d);
			a[d]:=i;
		end;
	if 2*d<k then writeln(f,-1)
	else
	begin
		if d>=k then writeln(f,a[k]);
		if d<k then writeln(f, n/a[2*d-k+1] :0:0);
	end;
	close(f);
end;
//
Begin
	doctep;
	ghitep;
end.

var i,o,k:longint; a:array[1..1000000] of int64;
    n,t:int64;
    Procedure QuickSort(L,R : longint);
  var
    i, j, x, t : longint;
  begin
    i := L; j := R; x:=a[L+random(R-L+1)];
    repeat
      while a[i] < x do i := i + 1;
      while a[j] > x do j := j - 1;
      if i<=j
         then begin
                t := a[i]; a[i] := a[j]; a[j] := t;
                i := i + 1; j := j - 1;
              end;
    until i>j;
    if L<j then QuickSort(L,j);
    if i<R then QuickSort(i,R);
  end;
 begin
 readln(n,k);
 for i:=1 to trunc(sqrt(n)) do
 if n mod i = 0 then begin
                     inc(o);
                     a[o]:=i;
                     if i*i<>n then begin
                     inc(o);
                     a[o]:=n div i end;
                     end;
     quicksort(1,o);
     if k>o then writeln(-1)
     else writeln(a[k]);
     end.

var i,o,k:longint; a:array[1..1000000] of int64;
    n,t:int64;
    Procedure QuickSort(L,R : longint);
  var
    i, j : longint;t,x:int64;
  begin
    i := L; j := R; x:=a[L+random(R-L+1)];
    repeat
      while a[i] < x do i := i + 1;
      while a[j] > x do j := j - 1;
      if i<=j
         then begin
                t := a[i]; a[i] := a[j]; a[j] := t;
                i := i + 1; j := j - 1;
              end;
    until i>j;
    if L<j then QuickSort(L,j);
    if i<R then QuickSort(i,R);
  end;
 begin
 readln(n,k);
 for i:=1 to trunc(sqrt(n)) do
 if n mod i = 0 then begin
                     inc(o);
                     a[o]:=i;
                     if i*i<>n then begin
                     inc(o);
                     a[o]:=n div i end;
                     end;
     quicksort(1,o);
     if k>o then writeln(-1)
     else writeln(a[k]);
     end.

var k,x,y,i:longint; data:boolean;
    n,t:int64;
 begin
 readln(n);
 t:=trunc(sqrt(n));
 y:=t;
 for i:=1 to y do
 if n mod i = 0 then begin
                     inc(x);
                     if x=k then begin
                                 write('i');
                                 data:=true;
                                 break
                                 end
                     end;
                   if not data then write(-1)
                   end.

program tmp15;
 var
  n:qword;
  flag:boolean;
  nx,i,k,t,all:longint;
 procedure away(x:longint);
  begin
   writeln(x);halt;
  end;
 begin
  readln(n,k);t:=0;
  nx:=trunc(sqrt(n));
  for i:=1 to nx do
   begin
    if n mod i=0 then
     begin
      inc(t);
      if t=k then away(i);
     end;
   end;
  all:=2*t;
  if nx*nx=k then dec(all);
  if k>all then away(-1);
  k:=2*t-k+1;
  t:=0;
  for i:=1 to nx do
   begin
    if n mod i=0 then
     begin
       inc(t);
       if t=k then away(n div i);
     end;
   end;
 end.

program tmp15;
 var
  n:qword;
  x:extended;
  flag:boolean;
  nx,i,k,t,all:longint;
 procedure away(x:qword);
  begin
   writeln(x);halt;
  end;
 begin
  readln(n,k);t:=0;
  nx:=trunc(sqrt(n));
  for i:=1 to nx do
   begin
    if n mod i=0 then
     begin
      inc(t);
      if t=k then away(i);
     end;
   end;
  all:=2*t;
  x:=sqrt(n);
  if x-nx<=1E-8 then dec(all);
  if k>all then
   begin
    writeln(-1);halt;
   end;
  k:=2*t-k+1;
  t:=0;
  for i:=1 to nx do
   begin
    if n mod i=0 then
     begin
       inc(t);
       if t=k then away(n div i);
     end;
   end;
 end.

var n,k,kol,kol2:int64;
    i:longint;
    a:array[1..100000]of int64;
begin
 read(n,k);
 for i:=1 to round(sqrt(n)) do
  begin
   if n mod i =0
    then begin
          inc(kol);
          a[kol]:=i;
         end;
  end;
 kol2:=kol;
 for i:=kol2 downto 1 do
  begin
   inc(kol);
   if n div a[i]<>a[i]
    then a[kol]:=n div a[i];
  end;
 if kol<k
  then write(-1)
  else write(a[k]);

end.

{$IFDEF ONLINE_JUDGE}
{$R-,Q-,S-,I-}
{$OPTIMIZATION LEVEL2}
{$INLINE ON}
{$ENDIF}

uses math;

procedure mofile;
begin
        {$IFDEF ONLINE_JUDGE}
        assign(input,'');
        reset(input);
        assign(output,'');
        rewrite(output);
        {$ELSE}
        assign(input,'');
        reset(input);
        assign(output,'');
        rewrite(output);
        {$ENDIF}
end;

procedure dongfile;
begin
        close(input);
        close(output);
end;

const
        maxc=1000000000+69;
        modulo=1000000000+7;

type
        re=record
                x,y:longint;
        end;

var
        n,k,m:int64;
        dem,cnt:longint;
        a:array[0..1000000] of longint;

procedure xuli;
var
        i:longint;
begin
        readln(n,k);
        dem:=1;
        for i:=1 to trunc(sqrt(n)) do
        if n mod i=0 then
        begin
                inc(dem);
                if n div i<>i then inc(dem);
        end;
        m:=dem;

        cnt:=0;
        for i:=1 to trunc(sqrt(n)) do
        if n mod i=0 then
        begin
                inc(cnt);
                a[cnt]:=i;
                if n div i<>i then
                begin
                        dec(dem);
                        a[dem]:=n div i;
                end;
        end;

        if k>=m then writeln(-1) else writeln(a[k]);
end;

begin
        mofile;
        xuli;
        dongfile;
end.

var n,k,count,result:int64;
	i,j:int32;
	A:array[1..10000] of int64;
Begin
	Read(n,k);
	result:=-1;
	count:=1;
	For i:=1 to trunc(sqrt(n)) do
		If n mod i=0 then
			Begin
				A[count]:=n div i;
				inc(count);
				If (count=k) then
					Begin
						Write(i);
						halt;
					End;
			End;

	dec(count,1);
	If (count*2>=k) then
		result:=A[2*count-k];

	Write(result);
End.

var n,k,count,result,i,j:int64;
	A,A1:array[1..10000000] of int64;
Begin
	Read(n,k);
	result:=-1;
	count:=0;
	j:=0;
	i:=1;
	While (i<=trunc(sqrt(n))) do
		Begin
			If n mod i=0 then
				Begin
					inc(count);
					//Write(i,' ');
					If (n div i<>i) then
						Begin
							inc(j);
							A[j]:=i;
						End;

					If (count=k) then
						Begin
							Write(i);
							halt;
						End;
				End;
			inc(i);
		End;

	A1[j]:=n;
	dec(k,count);
	i:=j;
	While(i>1) do
		Begin
			A1[j-i+1]:=A[i];
			dec(i);
		End;

	If (j>=k) then
		result:=n div A1[k];

	Write(result);
End.

var n,k,count,result:int64;
	i:int32;
Begin
	Read(n,k);
	result:=-1;
	For i:=1 to (n div 2)+1 do
		Begin
			If (i>round(sqrt(n))) and (count<2) then break;
			If n mod i=0 then
				Begin
					//Write(i,' ');
					inc(count);
					If (count=k) then
						Begin
							result:=i;
							break;
						End;
				End;
		End;
	//Writeln(count);
	Write(result);
End.

var n,k,count,result:int64;
	i:int32;
Begin
	Read(n,k);
	result:=-1;
	For i:=1 to (n div 2)+1 do
		Begin
			If (i>round(sqrt(n))) and (count<2) then break;
			If n mod i=0 then
				Begin
					//Write(i,' ');
					inc(count);
					If (count=k) then
						Begin
							result:=i;
							break;
						End;
				End;
		End;
	Writeln(count);
	Write(result);
End.

var n,k,count,result:int64;
	i,j:int32;
	A:array[1..10000] of int64;
Begin
	Read(n,k);
	result:=-1;
	count:=1;
	For i:=2 to trunc(sqrt(n)) do
		If n mod i=0 then
			Begin
				A[count]:=n div i;
				inc(count);
				If (count=k) then
					Begin
						Write(i);
						halt;
					End;
			End;

	A[count]:=n;
	If (k-count>0) then
		result:=A[k-count];

	Write(result);
End.

var n,k,count,result,i,j:int64;
	A,A1:array[1..10000000] of int64;
Begin
	Read(n,k);
	result:=-1;
	count:=0;
	j:=0;
	i:=1;
	While (i<=trunc(sqrt(n))) do
		Begin
			If n mod i=0 then
				Begin
					inc(count);
					//Write(i,' ');
					If (n div i<>i) then
						Begin
							inc(j);
							A[j]:=n div i;
						End;

					If (count=k) then
						Begin
							Write(i);
							halt;
						End;
				End;
			inc(i);
		End;

	dec(k,count);
	i:=j;
	While(i>1) do
		Begin
			A1[j-i+1]:=A[i];
			dec(i);
		End;
	If (count>=k+1) then
		result:=A1[k];

	Write(result);
End.

var i,j,k:longint;
    n:int64;
    a:array[1..1000000] of int64;

procedure quicksort(L,H : integer);
var
    i,j,pivot,y : integer;
begin
    i := L;
    j := H;
    pivot := a[random(H - L + 1) + L];

    repeat
        while a[i] < pivot do inc(i);
        while a[j] > pivot do dec(j);
        if i <= j then
        begin
        y:=a[i];
        a[i]:=a[j];
        a[j]:=y;
        inc(i);
        dec(j);
        end;
    until i > j;
    if L < j then quicksort(L,j);
    if i < H then quicksort(i,H);
end;

begin
read(n,k);
for i:=1 to round(sqrt(n)) do
if n mod i=0 then begin
                  inc(j); a[j]:=i;
                  if n div i<>i then begin
                                     inc(j);
                                     a[j]:=n div i;
                                     end;
                  end;
quicksort(1,j);
if k>j then write(-1) else write(a[k]);
end.

var i,f:longint;
n,m,k:int64;
a,b:array[0..1000000]of int64;
begin
readln(n,m);
for i:=1 to trunc(sqrt(n)) do
if n mod i=0 then
begin
inc(k);
a[k]:=i;
b[k]:=n div i;
end;
for i:=1 to k do
if m=i then
begin
writeln(a[i]);
f:=1;
break;
end;
if a[k]=b[1] then dec(k);
for i:=1 to k do
if m=i+k then
begin
writeln(b[i]);
f:=1;
break;
end;
if f=0 then writeln(-1);
end.

program z1;
var i,j,k,l,m,uk,un:longint; Z,Q:array[0..10000] of int64;  n,d,a,b,c,old:int64;

Procedure sort(l,r:longint);
var i,j:longint; x,y:int64;
begin
i:=l; j:=r; x:=Z[(l+r)>>1];
repeat
while Z[i]<x do inc(i);
while Z[j]>x do dec(j);
if not(i>j) then begin y:=Z[i]; Z[i]:=Z[j]; Z[j]:=y; inc(i); dec(j); end;
until (i>j);
if i<r then sort(i,r);
if l<j then sort(l,j);
end;

begin
//assign(input,'d:\input.txt'); reset(input);
//assign(output,'d:\output.txt'); rewrite(output);
readln(n,k);
d:=2;
while d*d<=n do
 begin
 if n mod d=0 then begin inc(uk); Q[uk]:=d; n:=n div d; end else if d=2 then d:=3 else d:=d+2;
 end;
if n<>1 then begin inc(uk); Q[uk]:=n; end;
Z[1]:=1; un:=1; old:=0;
for i:=1 to uk do
 begin
 a:=un;
 if Q[i]=Q[i-1] then b:=old else b:=1;
 for j:=a downto b do
  begin
  inc(un); Z[un]:=Z[j]*Q[i];
  end;
 old:=un;
 end;
sort(1,un);
if k>un then write('-1') else write(Z[k]);
end.

program z1;
var i,j,l,m,uk,un:longint; Z,Q:array[0..100000] of int64;  n,d,a,b,c,old,k:int64;

Procedure sort(l,r:longint);
var i,j:longint; x,y:int64;
begin
i:=l; j:=r; x:=Z[(l+r)>>1];
repeat
while Z[i]<x do inc(i);
while Z[j]>x do dec(j);
if not(i>j) then begin y:=Z[i]; Z[i]:=Z[j]; Z[j]:=y; inc(i); dec(j); end;
until (i>j);
if i<r then sort(i,r);
if l<j then sort(l,j);
end;

begin
//assign(input,'d:\input.txt'); reset(input);
//assign(output,'d:\output.txt'); rewrite(output);
readln(n,k);
d:=2;
while d*d<=n do
 begin
 if n mod d=0 then begin inc(uk); Q[uk]:=d; n:=n div d; end else if d=2 then d:=3 else d:=d+2;
 end;
if n<>1 then begin inc(uk); Q[uk]:=n; end;
Z[1]:=1; un:=1; old:=0;
for i:=1 to uk do
 begin
 a:=un;
 if Q[i]=Q[i-1] then b:=old else b:=1;
 for j:=a downto b do
  begin
  inc(un); Z[un]:=Z[j]*Q[i];
  end;
 old:=un;
 end;
sort(1,un);
if k>un then writeln('-1') else writeln(Z[k]);
//for i:=1 to un do write(Z[i],' ');
end.

program z1;
var i,j,l,m,uk,un,mark:longint; Z,Q:array[0..100000] of int64;  n,d,a,b,c,old,k:int64;

Procedure sort(l,r:longint);
var i,j:longint; x,y:int64;
begin
i:=l; j:=r; x:=Z[(l+r)>>1];
repeat
while Z[i]<x do inc(i);
while Z[j]>x do dec(j);
if not(i>j) then begin y:=Z[i]; Z[i]:=Z[j]; Z[j]:=y; inc(i); dec(j); end;
until (i>j);
if i<r then sort(i,r);
if l<j then sort(l,j);
end;

begin
//assign(input,'d:\input.txt'); reset(input);
//assign(output,'d:\output.txt'); rewrite(output);
readln(n,k);
for i:=1 to round(sqrt(n)) do
 begin
 if n mod i=0 then begin inc(a); Z[a]:=i; inc(a); Z[a]:=n div i; end;
 end;
sort(1,a);
writeln(Z[k]);
//writeln(un); for i:=1 to un do write(Z[i],' ');
end.

var
  a,k:int64;
  i:longint;
begin
readln(a,k);
for i:=1 to a do
  begin
  if (k = 1) and (a mod i = 0) then begin
                                    writeln(i);
                                    break;
                                    end;
  if a mod i = 0 then k:=k-1;
  end;
if k>0 then writeln('-1');
end.

var
  i,j:longint;
  n,k:int64;
  x:array[1..20000000]of int64;
procedure sort(l,r:longint);
var i,e,j,t:longint;
begin
  i:=l;
  j:=r;
  e:=x[l+random(r-l+1)];
  while i<=j do
  begin
    while e>x[i] do inc(i);
    while e<x[j] do dec(j);
    if i<=j then
    begin
    t:=x[i];x[i]:=x[j];x[j]:=t;
    inc(i);
    dec(j);
    end;
  end;
  if i<r then sort(i,r);
  if j>l then sort(l,j);
end;
begin
  read(n,k);
  j:=0;
  for i:=1 to trunc(sqrt(n)) do
  if n mod i=0 then
  begin
  inc(j);x[j]:=n div i;
  inc(j);x[j]:=i;
  end;

  if k>j then begin writeln(-1);halt;end;

  sort(1,j);

  //for i:=1 to j do
  //write(x[i],' ');

  writeln(x[k]);
end.

var
  i,j:longint;
  n,k:int64;
  x:array[1..20000000]of int64;
procedure sort(l,r:longint);
var i,e,j,t:longint;
begin
  i:=l;
  j:=r;
  e:=x[l+random(r-l+1)];
  while i<=j do
  begin
    while e>x[i] do inc(i);
    while e<x[j] do dec(j);
    if i<=j then
    begin
    t:=x[i];x[i]:=x[j];x[j]:=t;
    inc(i);
    dec(j);
    end;
  end;
  if i<r then sort(i,r);
  if j>l then sort(l,j);
end;
begin
  read(n,k);
  j:=0;
  for i:=1 to trunc(sqrt(n)) do
  if n mod i=0 then
  begin
  inc(j);x[j]:=n div i;
  if n div i<>i then begin
  inc(j);x[j]:=i;end;
  end;

  if k>j then begin writeln(-1);halt;end;

  sort(1,j);

  //for i:=1 to j do
  //write(x[i],' ');

  writeln(x[k]);
end.

var
   n:int64;
   m,k,i,j:longint;
   a:array[1..1000000] of longint;
begin
   readln (n,k);
   m:=round(sqrt(n));
   i:=1;
   j:=0;
   while (j<k)and(i<=m) do
   begin
      if n mod i=0 then
         begin inc(j);
         a[j]:=i;
         end;
      inc(i);
   end;
   i:=j;
   if j=k then writeln (a[k]) else
      begin
         while  (i>0)and(j<k) do
         begin
            inc(j);
            a[j]:=n div a[i];
            dec(i);
         end;
         if j=k then writeln (a[k]) else writeln (-1);
      end;
end.

var
   n:int64;
   m,k,i,j:longint;
   a:array[1..1000000] of int64;
begin
   readln (n,k);
   m:=round(sqrt(n));
   i:=1;
   j:=0;
   while (j<k)and(i<=m) do
   begin
      if n mod i=0 then
         begin inc(j);
         a[j]:=i;
         end;
      inc(i);
   end;
   i:=j;
   if j=k then writeln (a[k]) else
      begin
         while  (i>0)and(j<k) do
         begin
            inc(j);
            a[j]:=n div a[i];
            dec(i);
         end;
         if j=k then writeln (a[k]) else writeln (-1);
      end;
end.

Var ans1,ans2:array [1..10000] of int64;k,c,d,i,f:longint;n:int64;
Begin
        readln(n,k);d:=1;f:=0;
        while d*d<n do
        begin
        if n mod d =0 then
        begin
        writeln(d);
        c:=c+1;
        ans1[c]:=d;
        ans2[c]:=n div d;
        end;
        d:=d+1;
        end;
        i:=c*2;
        if d*d=n then
        begin
        c:=c+1;
        ans1[c]:=d;
        f:=1;
        i:=i+1;
        end;
        if k>i then
        writeln(-1)
        else
        if  (k>c) then
        writeln(ans2[i-k+1])
        else
        if k<=c then
        writeln(ans1[k])
        else

End.

Var ans1,ans2:array [1..10000000] of int64;k,c,d,i,f:longint;n:int64;
Begin
        readln(n,k);d:=1;f:=0;
        for d:=1 to round(sqrt(n)) do
        if n mod d =0 then
        begin
        c:=c+1;
        ans1[c]:=d;
        ans2[c]:=n div d;
        end;
        i:=c*2;
        if d*d=n then
        begin
        c:=c+1;
        ans1[c]:=d;
        f:=1;
        i:=i+1;
        end;
        if k>i then
        writeln(-1)
        else
        if  (k>c) then
        writeln(ans2[i-k+1])
        else
        if k<=c then
        writeln(ans1[k])
End.

Var ans1,ans2:array [1..30000] of int64;k,c,d,i,f:longint;n:int64;
Begin
        readln(n,k);d:=1;f:=0;
        for d:=1 to round(sqrt(n)) do

        if n mod d =0 then
        begin
        c:=c+1;
        ans1[c]:=d;
        ans2[c]:=n div d;
        end;
        i:=c*2;
        if d*d=n then
        begin
        c:=c+1;
        ans1[c]:=d;
        f:=1;
        i:=i+1;
        end;
        if k>i then
        writeln(-1)
        else
        if  (k>c) then
        writeln(ans2[i-k+1])
        else
        if k<=c then
        writeln(ans1[k])
End.

Var ans1,ans2:array [1..10000] of int64;k,c,d,i,f:longint;n:int64;
Begin
        readln(n,k);d:=1;f:=0;
        while d*d<n do
        begin
        if n mod d =0 then
        begin
        c:=c+1;
        ans1[c]:=d;
        ans2[c]:=n div d;
        end;
        d:=d+1;
        end;
        i:=c*2;
        if d*d=n then
        begin
        c:=c+1;
        ans1[c]:=d;
        f:=1;
        i:=i+1;
        end;
        if k>i then
        writeln(-1)
        else
        if  (k>c) then
        writeln(ans2[i-k+1])
        else
        if k<=c then
        writeln(ans1[k])
        else

End.

Var ans1,ans2:array [1..10000000] of int64;k,c,d,i,f:longint;n:int64;
Begin
        readln(n,k);d:=1;f:=0;
        if (n=1) and (k>=2) then
        begin
        writeln(-1);
        halt;
        end;
        for d:=1 to round(sqrt(n)) do
        if n mod d =0 then
        begin
        c:=c+1;
        ans1[c]:=d;
        ans2[c]:=n div d;
        end;
        i:=c*2;
        if d*d=n then
        begin
        c:=c+1;
        ans1[c]:=d;
        f:=1;
        i:=i+1;
        end;
        if k>i then
        writeln(-1)
        else
        if  (k>c) then
        writeln(ans2[i-k+1])
        else
        if k<=c then
        writeln(ans1[k])
End.

Var ans1,ans2:array [1..10000000] of int64;k,c,d,i,f:longint;n:int64;
Begin
        readln(n,k);d:=1;f:=0;
        for i:=1 to round(sqrt(n)) do
        if n mod d =0 then
        begin
        c:=c+1;
        ans1[c]:=d;
        ans2[c]:=n div d;
        end;
        i:=c*2;
        if d*d=n then
        begin
        c:=c+1;
        ans1[c]:=d;
        f:=1;
        i:=i+1;
        end;
        if k>i then
        writeln(-1)
        else
        if  (k>c) then
        writeln(ans2[i-k+1])
        else
        if k<=c then
        writeln(ans1[k])
        else

End.

var f1,f2 : text;
    a : array[1..10000000] of int64;
    kt : boolean;
    n,k,t,d : int64;
    i : longint;

begin
assign(f1,'') ; reset(f1);
assign(f2,'') ; rewrite(f2);
readln(f1,n,k);
kt := false;
for i := 1 to trunc(sqrt(n)) do
        if n mod i = 0 then
                begin
                inc(d);
                a[d] := i;
                if i*i = n then
                        kt := true;
                end;
t := d*2;
if kt = true then dec(t);
if k > t then
        begin
        write(f2,-1);
        close(f1);
        close(f2);
        halt;
        end;
for i := 1 to d do
        if k = i then
                begin
                write(f2,a[i]);
                close(f1);
                close(f2);
                halt
                end
           else if i + d = k then
                        begin
                        write(f2,n div a[i]);
                        close(f1);
                        close(f2);
                        halt
                        end;
close(f1);
close(f2);
end.

var f1,f2 : text;
    a : array[1..10000000] of int64;
    kt : boolean;
    n,k,t,d : int64;
    i : longint;

begin
assign(f1,'') ; reset(f1);
assign(f2,'') ; rewrite(f2);
readln(f1,n,k);
kt := false;
for i := 1 to trunc(sqrt(n)) do
        if n mod i = 0 then
                begin
                inc(d);
                a[d] := i;
                end;
if trunc(sqrt(n)) * trunc(sqrt(n)) = n then kt := true;
t := d*2;
if kt = true then dec(t);
if k > t then
        begin
        write(f2,-1);
        close(f1);
        close(f2);
        halt;
        end;
for i := 1 to d do
        if k = i then
                begin
                write(f2,a[i]);
                close(f1);
                close(f2);
                halt
                end
           else if i + d = k then
                        begin
                        write(f2,n div a[i]);
                        close(f1);
                        close(f2);
                        halt
                        end;
close(f1);
close(f2);
end.

const   fi='';
        fo='';
var     f,g             :text;
        n,k                     :int64;
        a                       :array[0..100002] of int64;
procedure nhap;
begin
        assign(f,fi);reset(f);
        assign(g,fo);rewrite(g);
        readln(f,n,k);
        close(f);
end;

procedure main;
var   dem,i,u     :longint;
begin
        dem:=0;
        for i:=1 to trunc(sqrt(n)) do
                if n mod i =0 then
                        begin
                                inc(dem);a[dem]:=i;
                        end;
        u:=ord(sqr(trunc(sqrt(n)))=n);
        if dem*2-u<k then begin writeln(g,-1);exit;end;

        if dem>=k then writeln(g,a[dem])
        else writeln(g,n div a[dem-(k-dem)+1-u]);
end;

BEGIN
        Nhap;
        main;
        close(g);
END.

var s,i,e:longint;
n,k,a:int64;
begin
   {assign(input,'input.txt');
   assign(output,'output.txt');
   reset(input);
   rewrite(output);}
   read(n,k);
   s:=trunc(sqrt(n));
   for i:=1 to s do
   if n mod i=0 then
   begin
      inc(e);
      a:=i;
      if e=k then break;
   end;
   if (n mod 2=0)and(e<k) then
   begin
      inc(e);
      a:=n div 2;
   end;
   if e+1=k then
   begin
      inc(e);
      a:=n;
   end;
   if e<k then write(-1) else write(a);
end.

var s,i,e:longint;
n,k,a:int64;
begin
   {assign(input,'input.txt');
   assign(output,'output.txt');
   reset(input);
   rewrite(output);}
   read(n,k);
   s:=trunc(sqrt(n))+1;
   for i:=1 to s do
   if n mod i=0 then
   begin
      inc(e);
      a:=i;
      if e=k then break;
   end;
   if (n mod 2=0)and(e<k) then
   begin
      inc(e);
      a:=n div 2;
   end;
   if e+1=k then
   begin
      inc(e);
      a:=n;
   end;
   if e<k then write(-1) else write(a);
end.

var
 n,k,m,t,stn: int64;
 i: longint;
 st: array [0..32000000] of int64;
begin
 readln(n,k);
 m:=trunc(sqrt(n));

 if (n = 1) and (k > 1) then begin writeln(-1); halt; end;

 for i:=1 to m do if n mod i = 0 then
 begin
  inc(t);
  st[t]:=n div i;
  if t = k then begin writeln(i); halt; end;
 end;

 stn:=t;
 for i:=stn downto 1 do if n mod st[i] = 0 then
 begin
  inc(t);
  if t = k then begin writeln(st[i]); halt; end;
 end;

 writeln(-1);
end.

program O_O;
type
	ll=longint;
	bo=boolean;
	arr=array[0..10000000] of int64;
var
	i,k:ll;
	n,j:int64;
	a:arr;
begin
	readln(n,k);
	j:=0;
	for i:=1 to trunc(sqrt(n)+0.5) do
	begin
		if n mod i=0 then
		begin
			inc(j);
			a[j]:=i;
		end;
	end;
	if k>2*j then writeln(-1)
	else
		if k<=j then writeln(a[k])
	else
		writeln(n div a[2*j+1-k]);
end.

program O_O;
type
	ll=longint;
	bo=boolean;
	arr=array[0..10000000] of int64;
var
	i,j,k:ll;
	n:int64;
	a:arr;
begin
	readln(n,k);
	j:=0;
	for i:=1 to trunc(sqrt(n)+0.5) do
	begin
		if n mod i=0 then
		begin
			inc(j);
			a[j]:=i;
		end;
	end;
	if k>2*j then writeln(-1)
	else
		if k<=j then writeln(a[k])
	else
		writeln( n div a[k-j]);
end.

program O_O;
type
	ll=longint;
	bo=boolean;
	arr=array[0..10000000] of int64;
var
	i,k:ll;
	n,j:int64;
	a:arr;
begin
	readln(n,k);
	j:=0;
	for i:=1 to trunc(sqrt(n)+0.5) do
	begin
		if n mod i=0 then
		begin
			inc(j);
			a[j]:=i;
		end;
	end;
	if (k>2*j)or((j=1)and (k>j) ) then writeln(-1)
	else
		if k<=j then writeln(a[k])
	else
		writeln(n div a[2*j+1-k]);
end.

var n,k,q,j:int64;
    i:longint;
    t:array [1..100000] of int64;
begin
  readln(n,k);
  q:=0;
  j:=0;
  for i:=1 to trunc(sqrt(n)) do
    if n mod i = 0 then inc(q,2);

  if q < k then begin writeln(-1); exit; end;

  for i:=1 to trunc(sqrt(n)) do
    if n mod i = 0 then begin inc(j); t[j]:=i; t[q-j+1]:=n div i; end;

  writeln(t[k]);

end.