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 C =Math.min(A,B);
    int D[] =new int[K];
    int x =0;
    for(int i=C;i>0;i--){
      if(!(B%i==0)){continue;}
      if(!(A%i==0)){continue;}
      D[x]=i;
      x=x+1;
      if(x==K){break;}}
    System.out.println(D[K-1]);
  }
} 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 C =Math.min(A,B);
    int D[] =new int[K];
    int x =0;
    for(int i=C;i>0;i--){
      if(!(B%i==0)){continue;}
      if(!(A%i==0)){continue;}
      D[x]=i;
      x=x+1;
      if(x==K){break;}}
    System.out.println(D[K-1]);
  }
} 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 D[] =new int[K];
    int x =0;
    for(int i=C;i>0;i--){
      if(!(B%i==0)){continue;}
      if(!(A%i==0)){continue;}
      D[x]=i;
      x=x+1;
      if(x==K){break;}}
    System.out.println(D[K-1]);
  } 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 D[] =new int[K];
    int x =0;
    for(int i=C;i>0;i--){
      if(!(B%i==0)){continue;}
      if(!(A%i==0)){continue;}
      D[x]=i;
      x=x+1;
      if(x==K){break;}}
    System.out.println(D[K-1]);
  } 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 D[] =new int[K]; D new int[K] K int x =0; x 0 for(int i=C;i>0;i--){
      if(!(B%i==0)){continue;}
      if(!(A%i==0)){continue;}
      D[x]=i;
      x=x+1;
      if(x==K){break;}} int i=C; int i=C; i C i>0 i 0 i-- i-- i {
      if(!(B%i==0)){continue;}
      if(!(A%i==0)){continue;}
      D[x]=i;
      x=x+1;
      if(x==K){break;}} {
      if(!(B%i==0)){continue;}
      if(!(A%i==0)){continue;}
      D[x]=i;
      x=x+1;
      if(x==K){break;}} if(!(B%i==0)){continue;} !(B%i==0) (B%i==0) B%i B i 0 {continue;} continue; if(!(A%i==0)){continue;} !(A%i==0) (A%i==0) A%i A i 0 {continue;} continue; D[x]=i D[x] D x i x=x+1 x x+1 x 1 if(x==K){break;} x==K x K {break;} break; System.out.println(D[K-1]) System.out.println System.out System System.out D[K-1] D K-1 K 1 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 C =Math.min(A,B);
    int D[] =new int[K];
    int x =0;
    for(int i=C;i>0;i--){
      if(!(B%i==0)){continue;}
      if(!(A%i==0)){continue;}
      D[x]=i;
      x=x+1;
      if(x==K){break;}}
    System.out.println(D[K-1]);
  }
} 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 C =Math.min(A,B);
    int D[] =new int[K];
    int x =0;
    for(int i=C;i>0;i--){
      if(!(B%i==0)){continue;}
      if(!(A%i==0)){continue;}
      D[x]=i;
      x=x+1;
      if(x==K){break;}}
    System.out.println(D[K-1]);
  }
} 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 C =Math.min(A,B);
    int D[] =new int[K];
    int x =0;
    for(int i=C;i>0;i--){
      if(!(B%i==0)){continue;}
      if(!(A%i==0)){continue;}
      D[x]=i;
      x=x+1;
      if(x==K){break;}}
    System.out.println(D[K-1]);
  }
}