import 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();
    int p[] = new int[110];
    int cnt=0;
    for(int i =0;i<110;i++){
      p[i]=100000000;
    }
    for(int i=0;i<100;i++){
      if(a%(i+1)==0&&b%(i+1)==0){
        p[i]=i+1;
        cnt=cnt+1;
      }
    }
    Arrays.sort(p);
//    for(int i=0;i<10;i++){
//    System.out.println(p[i]);
//      }
    System.out.println(p[cnt-k]);
      
      
  }
  

  
} import java.util.*; util.* java 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();
    int p[] = new int[110];
    int cnt=0;
    for(int i =0;i<110;i++){
      p[i]=100000000;
    }
    for(int i=0;i<100;i++){
      if(a%(i+1)==0&&b%(i+1)==0){
        p[i]=i+1;
        cnt=cnt+1;
      }
    }
    Arrays.sort(p);
//    for(int i=0;i<10;i++){
//    System.out.println(p[i]);
//      }
    System.out.println(p[cnt-k]);
      
      
  }
  

  
} 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();
    int p[] = new int[110];
    int cnt=0;
    for(int i =0;i<110;i++){
      p[i]=100000000;
    }
    for(int i=0;i<100;i++){
      if(a%(i+1)==0&&b%(i+1)==0){
        p[i]=i+1;
        cnt=cnt+1;
      }
    }
    Arrays.sort(p);
//    for(int i=0;i<10;i++){
//    System.out.println(p[i]);
//      }
    System.out.println(p[cnt-k]);
      
      
  } main {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int k = sc.nextInt();
    int p[] = new int[110];
    int cnt=0;
    for(int i =0;i<110;i++){
      p[i]=100000000;
    }
    for(int i=0;i<100;i++){
      if(a%(i+1)==0&&b%(i+1)==0){
        p[i]=i+1;
        cnt=cnt+1;
      }
    }
    Arrays.sort(p);
//    for(int i=0;i<10;i++){
//    System.out.println(p[i]);
//      }
    System.out.println(p[cnt-k]);
      
      
  } 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 int p[] = new int[110]; p new int[110] 110 int cnt=0; cnt 0 for(int i =0;i<110;i++){
      p[i]=100000000;
    } int i =0; int i =0; i 0 i<110 i 110 i++ i++ i {
      p[i]=100000000;
    } {
      p[i]=100000000;
    } p[i]=100000000 p[i] p i 100000000 for(int i=0;i<100;i++){
      if(a%(i+1)==0&&b%(i+1)==0){
        p[i]=i+1;
        cnt=cnt+1;
      }
    } int i=0; int i=0; i 0 i<100 i 100 i++ i++ i {
      if(a%(i+1)==0&&b%(i+1)==0){
        p[i]=i+1;
        cnt=cnt+1;
      }
    } {
      if(a%(i+1)==0&&b%(i+1)==0){
        p[i]=i+1;
        cnt=cnt+1;
      }
    } if(a%(i+1)==0&&b%(i+1)==0){
        p[i]=i+1;
        cnt=cnt+1;
      } a%(i+1)==0&&b%(i+1)==0 a%(i+1)==0 a%(i+1) a (i+1) i 1 0 b%(i+1)==0 b%(i+1) b (i+1) i 1 0 {
        p[i]=i+1;
        cnt=cnt+1;
      } p[i]=i+1 p[i] p i i+1 i 1 cnt=cnt+1 cnt cnt+1 cnt 1 Arrays.sort(p) Arrays.sort Arrays p System.out.println(p[cnt-k]) System.out.println System.out System System.out p[cnt-k] p cnt-k cnt k 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();
    int p[] = new int[110];
    int cnt=0;
    for(int i =0;i<110;i++){
      p[i]=100000000;
    }
    for(int i=0;i<100;i++){
      if(a%(i+1)==0&&b%(i+1)==0){
        p[i]=i+1;
        cnt=cnt+1;
      }
    }
    Arrays.sort(p);
//    for(int i=0;i<10;i++){
//    System.out.println(p[i]);
//      }
    System.out.println(p[cnt-k]);
      
      
  }
  

  
} 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();
    int p[] = new int[110];
    int cnt=0;
    for(int i =0;i<110;i++){
      p[i]=100000000;
    }
    for(int i=0;i<100;i++){
      if(a%(i+1)==0&&b%(i+1)==0){
        p[i]=i+1;
        cnt=cnt+1;
      }
    }
    Arrays.sort(p);
//    for(int i=0;i<10;i++){
//    System.out.println(p[i]);
//      }
    System.out.println(p[cnt-k]);
      
      
  }
  

  
} Main
import 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();
    int p[] = new int[110];
    int cnt=0;
    for(int i =0;i<110;i++){
      p[i]=100000000;
    }
    for(int i=0;i<100;i++){
      if(a%(i+1)==0&&b%(i+1)==0){
        p[i]=i+1;
        cnt=cnt+1;
      }
    }
    Arrays.sort(p);
//    for(int i=0;i<10;i++){
//    System.out.println(p[i]);
//      }
    System.out.println(p[cnt-k]);
      
      
  }
  

  
}