import java.util.Scanner;
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 C = Math.min(A,B);
    int count = 0;
    
    for(int i=1;i<=C;i++){
      if(A%i==0 && B%i==0){
        count++;
      }
    }
    int[] line = new int[count];
    int cc = 0;
    for(int j=1;j<=C;j++){
      if(A%j==0 && B%j==0){
        line[cc] = j;
        cc++;
      }
    }
   System.out.println(line[line.length-K]);
  }
} import java.util.Scanner; Scanner java.util 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 C = Math.min(A,B);
    int count = 0;
    
    for(int i=1;i<=C;i++){
      if(A%i==0 && B%i==0){
        count++;
      }
    }
    int[] line = new int[count];
    int cc = 0;
    for(int j=1;j<=C;j++){
      if(A%j==0 && B%j==0){
        line[cc] = j;
        cc++;
      }
    }
   System.out.println(line[line.length-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 C = Math.min(A,B);
    int count = 0;
    
    for(int i=1;i<=C;i++){
      if(A%i==0 && B%i==0){
        count++;
      }
    }
    int[] line = new int[count];
    int cc = 0;
    for(int j=1;j<=C;j++){
      if(A%j==0 && B%j==0){
        line[cc] = j;
        cc++;
      }
    }
   System.out.println(line[line.length-K]);
  } main {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int K = sc.nextInt();
    int C = Math.min(A,B);
    int count = 0;
    
    for(int i=1;i<=C;i++){
      if(A%i==0 && B%i==0){
        count++;
      }
    }
    int[] line = new int[count];
    int cc = 0;
    for(int j=1;j<=C;j++){
      if(A%j==0 && B%j==0){
        line[cc] = j;
        cc++;
      }
    }
   System.out.println(line[line.length-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 C = Math.min(A,B); C Math.min(A,B) Math.min Math A B int count = 0; count 0 for(int i=1;i<=C;i++){
      if(A%i==0 && B%i==0){
        count++;
      }
    } int i=1; int i=1; i 1 i<=C i C i++ i++ i {
      if(A%i==0 && B%i==0){
        count++;
      }
    } {
      if(A%i==0 && B%i==0){
        count++;
      }
    } if(A%i==0 && B%i==0){
        count++;
      } A%i==0 && B%i==0 A%i==0 A%i A i 0 B%i==0 B%i B i 0 {
        count++;
      } count++ count int[] line = new int[count]; line new int[count] count int cc = 0; cc 0 for(int j=1;j<=C;j++){
      if(A%j==0 && B%j==0){
        line[cc] = j;
        cc++;
      }
    } int j=1; int j=1; j 1 j<=C j C j++ j++ j {
      if(A%j==0 && B%j==0){
        line[cc] = j;
        cc++;
      }
    } {
      if(A%j==0 && B%j==0){
        line[cc] = j;
        cc++;
      }
    } if(A%j==0 && B%j==0){
        line[cc] = j;
        cc++;
      } A%j==0 && B%j==0 A%j==0 A%j A j 0 B%j==0 B%j B j 0 {
        line[cc] = j;
        cc++;
      } line[cc] = j line[cc] line cc j cc++ cc System.out.println(line[line.length-K]) System.out.println System.out System System.out line[line.length-K] line line.length-K line.length line line.length K String[] args args
import java.util.Scanner;
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 C = Math.min(A,B);
    int count = 0;
    
    for(int i=1;i<=C;i++){
      if(A%i==0 && B%i==0){
        count++;
      }
    }
    int[] line = new int[count];
    int cc = 0;
    for(int j=1;j<=C;j++){
      if(A%j==0 && B%j==0){
        line[cc] = j;
        cc++;
      }
    }
   System.out.println(line[line.length-K]);
  }
}