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[] num = new int[101];
        int cnt = 0;

        for(int i =1;i<101;i++){
            if(a%i==0 && b%i==0){
                cnt++;
                num[cnt] = i;
                //System.out.println(i);
            }
        }

        System.out.println(num[cnt-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[] num = new int[101];
        int cnt = 0;

        for(int i =1;i<101;i++){
            if(a%i==0 && b%i==0){
                cnt++;
                num[cnt] = i;
                //System.out.println(i);
            }
        }

        System.out.println(num[cnt-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[] num = new int[101];
        int cnt = 0;

        for(int i =1;i<101;i++){
            if(a%i==0 && b%i==0){
                cnt++;
                num[cnt] = i;
                //System.out.println(i);
            }
        }

        System.out.println(num[cnt-k+1]);
      
    } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        int[] num = new int[101];
        int cnt = 0;

        for(int i =1;i<101;i++){
            if(a%i==0 && b%i==0){
                cnt++;
                num[cnt] = i;
                //System.out.println(i);
            }
        }

        System.out.println(num[cnt-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[] num = new int[101]; num new int[101] 101 int cnt = 0; cnt 0 for(int i =1;i<101;i++){
            if(a%i==0 && b%i==0){
                cnt++;
                num[cnt] = i;
                //System.out.println(i);
            }
        } int i =1; int i =1; i 1 i<101 i 101 i++ i++ i {
            if(a%i==0 && b%i==0){
                cnt++;
                num[cnt] = i;
                //System.out.println(i);
            }
        } {
            if(a%i==0 && b%i==0){
                cnt++;
                num[cnt] = i;
                //System.out.println(i);
            }
        } if(a%i==0 && b%i==0){
                cnt++;
                num[cnt] = i;
                //System.out.println(i);
            } a%i==0 && b%i==0 a%i==0 a%i a i 0 b%i==0 b%i b i 0 {
                cnt++;
                num[cnt] = i;
                //System.out.println(i);
            } cnt++ cnt num[cnt] = i num[cnt] num cnt i System.out.println(num[cnt-k+1]) System.out.println System.out System System.out num[cnt-k+1] num cnt-k+1 cnt-k cnt 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[] num = new int[101];
        int cnt = 0;

        for(int i =1;i<101;i++){
            if(a%i==0 && b%i==0){
                cnt++;
                num[cnt] = i;
                //System.out.println(i);
            }
        }

        System.out.println(num[cnt-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[] num = new int[101];
        int cnt = 0;

        for(int i =1;i<101;i++){
            if(a%i==0 && b%i==0){
                cnt++;
                num[cnt] = i;
                //System.out.println(i);
            }
        }

        System.out.println(num[cnt-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[] num = new int[101];
        int cnt = 0;

        for(int i =1;i<101;i++){
            if(a%i==0 && b%i==0){
                cnt++;
                num[cnt] = i;
                //System.out.println(i);
            }
        }

        System.out.println(num[cnt-k+1]);
      
    }
}
