import java.util.*;
import java.lang.*;

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 i = -1;
        if(a>b){
            i = b;
        }else{
            i = a;
        }
        int count = 0;
        while(true){
            if(a%i==0&&b%i==0){
                count++;
            }
            if(count == k){break;}
            i--;
        }
        System.out.println(i);
        sc.close();
    }
} import java.util.*; util.* java import java.lang.*; lang.* 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 i = -1;
        if(a>b){
            i = b;
        }else{
            i = a;
        }
        int count = 0;
        while(true){
            if(a%i==0&&b%i==0){
                count++;
            }
            if(count == k){break;}
            i--;
        }
        System.out.println(i);
        sc.close();
    }
} 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 i = -1;
        if(a>b){
            i = b;
        }else{
            i = a;
        }
        int count = 0;
        while(true){
            if(a%i==0&&b%i==0){
                count++;
            }
            if(count == k){break;}
            i--;
        }
        System.out.println(i);
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        int i = -1;
        if(a>b){
            i = b;
        }else{
            i = a;
        }
        int count = 0;
        while(true){
            if(a%i==0&&b%i==0){
                count++;
            }
            if(count == k){break;}
            i--;
        }
        System.out.println(i);
        sc.close();
    } 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 i = -1; i -1 1 if(a>b){
            i = b;
        }else{
            i = a;
        } a>b a b {
            i = b;
        } i = b i b {
            i = a;
        } i = a i a int count = 0; count 0 while(true){
            if(a%i==0&&b%i==0){
                count++;
            }
            if(count == k){break;}
            i--;
        } true {
            if(a%i==0&&b%i==0){
                count++;
            }
            if(count == k){break;}
            i--;
        } 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 if(count == k){break;} count == k count k {break;} break; i-- i System.out.println(i) System.out.println System.out System System.out i sc.close() sc.close sc 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 i = -1;
        if(a>b){
            i = b;
        }else{
            i = a;
        }
        int count = 0;
        while(true){
            if(a%i==0&&b%i==0){
                count++;
            }
            if(count == k){break;}
            i--;
        }
        System.out.println(i);
        sc.close();
    }
} 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 i = -1;
        if(a>b){
            i = b;
        }else{
            i = a;
        }
        int count = 0;
        while(true){
            if(a%i==0&&b%i==0){
                count++;
            }
            if(count == k){break;}
            i--;
        }
        System.out.println(i);
        sc.close();
    }
} Main
import java.util.*;
import java.lang.*;

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 i = -1;
        if(a>b){
            i = b;
        }else{
            i = a;
        }
        int count = 0;
        while(true){
            if(a%i==0&&b%i==0){
                count++;
            }
            if(count == k){break;}
            i--;
        }
        System.out.println(i);
        sc.close();
    }
}