import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int A = sc.nextInt();
   int B = sc.nextInt();
   int K = sc.nextInt();

   if(B>A)
   {
    int s =B;
    B = A;
    A = s;
   }
   
   int count =0;
   int ans=0;
   int cd = B;
   while(count<K)
   {
     if(A%cd==0 && B%cd ==0) 
     {
       count++;
       ans = cd;
     }
     cd--;
   }
   System.out.println(ans);
 }
} import java.util.Scanner; Scanner java.util public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int A = sc.nextInt();
   int B = sc.nextInt();
   int K = sc.nextInt();

   if(B>A)
   {
    int s =B;
    B = A;
    A = s;
   }
   
   int count =0;
   int ans=0;
   int cd = B;
   while(count<K)
   {
     if(A%cd==0 && B%cd ==0) 
     {
       count++;
       ans = cd;
     }
     cd--;
   }
   System.out.println(ans);
 }
} Main public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int A = sc.nextInt();
   int B = sc.nextInt();
   int K = sc.nextInt();

   if(B>A)
   {
    int s =B;
    B = A;
    A = s;
   }
   
   int count =0;
   int ans=0;
   int cd = B;
   while(count<K)
   {
     if(A%cd==0 && B%cd ==0) 
     {
       count++;
       ans = cd;
     }
     cd--;
   }
   System.out.println(ans);
 } main {
   Scanner sc = new Scanner(System.in);
   int A = sc.nextInt();
   int B = sc.nextInt();
   int K = sc.nextInt();

   if(B>A)
   {
    int s =B;
    B = A;
    A = s;
   }
   
   int count =0;
   int ans=0;
   int cd = B;
   while(count<K)
   {
     if(A%cd==0 && B%cd ==0) 
     {
       count++;
       ans = cd;
     }
     cd--;
   }
   System.out.println(ans);
 } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int A = sc.nextInt(); A sc.nextInt() sc.nextInt sc int B = sc.nextInt(); B sc.nextInt() sc.nextInt sc int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc if(B>A)
   {
    int s =B;
    B = A;
    A = s;
   } B>A B A {
    int s =B;
    B = A;
    A = s;
   } int s =B; s B B = A B A A = s A s int count =0; count 0 int ans=0; ans 0 int cd = B; cd B while(count<K)
   {
     if(A%cd==0 && B%cd ==0) 
     {
       count++;
       ans = cd;
     }
     cd--;
   } count<K count K {
     if(A%cd==0 && B%cd ==0) 
     {
       count++;
       ans = cd;
     }
     cd--;
   } if(A%cd==0 && B%cd ==0) 
     {
       count++;
       ans = cd;
     } A%cd==0 && B%cd ==0 A%cd==0 A%cd A cd 0 B%cd ==0 B%cd B cd 0 {
       count++;
       ans = cd;
     } count++ count ans = cd ans cd cd-- cd System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int A = sc.nextInt();
   int B = sc.nextInt();
   int K = sc.nextInt();

   if(B>A)
   {
    int s =B;
    B = A;
    A = s;
   }
   
   int count =0;
   int ans=0;
   int cd = B;
   while(count<K)
   {
     if(A%cd==0 && B%cd ==0) 
     {
       count++;
       ans = cd;
     }
     cd--;
   }
   System.out.println(ans);
 }
} public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int A = sc.nextInt();
   int B = sc.nextInt();
   int K = sc.nextInt();

   if(B>A)
   {
    int s =B;
    B = A;
    A = s;
   }
   
   int count =0;
   int ans=0;
   int cd = B;
   while(count<K)
   {
     if(A%cd==0 && B%cd ==0) 
     {
       count++;
       ans = cd;
     }
     cd--;
   }
   System.out.println(ans);
 }
} Main
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int A = sc.nextInt();
   int B = sc.nextInt();
   int K = sc.nextInt();

   if(B>A)
   {
    int s =B;
    B = A;
    A = s;
   }
   
   int count =0;
   int ans=0;
   int cd = B;
   while(count<K)
   {
     if(A%cd==0 && B%cd ==0) 
     {
       count++;
       ans = cd;
     }
     cd--;
   }
   System.out.println(ans);
 }
}