import java.util.Scanner;
 
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[] n = new int[100];
 
        int min = Math.min(a, b);
        int cnt = 0;
        for (int i = 1; i <= min; i++) {
            if (a % i == 0 && b % i == 0)
                n[cnt++] = i;
            else
                continue;
        }
        
        System.out.println(n[cnt - k]);
    }
} import java.util.Scanner; Scanner 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[] n = new int[100];
 
        int min = Math.min(a, b);
        int cnt = 0;
        for (int i = 1; i <= min; i++) {
            if (a % i == 0 && b % i == 0)
                n[cnt++] = i;
            else
                continue;
        }
        
        System.out.println(n[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[] n = new int[100];
 
        int min = Math.min(a, b);
        int cnt = 0;
        for (int i = 1; i <= min; i++) {
            if (a % i == 0 && b % i == 0)
                n[cnt++] = i;
            else
                continue;
        }
        
        System.out.println(n[cnt - k]);
    } main {
        Scanner sc = new Scanner(System.in);
 
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        int[] n = new int[100];
 
        int min = Math.min(a, b);
        int cnt = 0;
        for (int i = 1; i <= min; i++) {
            if (a % i == 0 && b % i == 0)
                n[cnt++] = i;
            else
                continue;
        }
        
        System.out.println(n[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[] n = new int[100]; n new int[100] 100 int min = Math.min(a, b); min Math.min(a, b) Math.min Math a b int cnt = 0; cnt 0 for (int i = 1; i <= min; i++) {
            if (a % i == 0 && b % i == 0)
                n[cnt++] = i;
            else
                continue;
        } int i = 1; int i = 1; i 1 i <= min i min i++ i++ i {
            if (a % i == 0 && b % i == 0)
                n[cnt++] = i;
            else
                continue;
        } {
            if (a % i == 0 && b % i == 0)
                n[cnt++] = i;
            else
                continue;
        } if (a % i == 0 && b % i == 0)
                n[cnt++] = i;
            else
                continue; a % i == 0 && b % i == 0 a % i == 0 a % i a i 0 b % i == 0 b % i b i 0 n[cnt++] = i n[cnt++] n cnt++ cnt i continue; System.out.println(n[cnt - k]) System.out.println System.out System System.out n[cnt - k] n 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[] n = new int[100];
 
        int min = Math.min(a, b);
        int cnt = 0;
        for (int i = 1; i <= min; i++) {
            if (a % i == 0 && b % i == 0)
                n[cnt++] = i;
            else
                continue;
        }
        
        System.out.println(n[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[] n = new int[100];
 
        int min = Math.min(a, b);
        int cnt = 0;
        for (int i = 1; i <= min; i++) {
            if (a % i == 0 && b % i == 0)
                n[cnt++] = i;
            else
                continue;
        }
        
        System.out.println(n[cnt - k]);
    }
} Main
import java.util.Scanner;
 
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[] n = new int[100];
 
        int min = Math.min(a, b);
        int cnt = 0;
        for (int i = 1; i <= min; i++) {
            if (a % i == 0 && b % i == 0)
                n[cnt++] = i;
            else
                continue;
        }
        
        System.out.println(n[cnt - k]);
    }
}