import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int A = Integer.parseInt(sc.next());
	int B = Integer.parseInt(sc.next());
	int K = Integer.parseInt(sc.next());
	int[] arr = new int[100];
	int cnt = 0;
	for(int i = 1; i<=Math.min(A,B); i++) {
	    if(A%i==0 && B%i == 0) {
		arr[cnt] = i;
		cnt++;
	    }
	}
	Arrays.sort(arr);
	System.out.println(arr[arr.length-K]);
    }
} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int A = Integer.parseInt(sc.next());
	int B = Integer.parseInt(sc.next());
	int K = Integer.parseInt(sc.next());
	int[] arr = new int[100];
	int cnt = 0;
	for(int i = 1; i<=Math.min(A,B); i++) {
	    if(A%i==0 && B%i == 0) {
		arr[cnt] = i;
		cnt++;
	    }
	}
	Arrays.sort(arr);
	System.out.println(arr[arr.length-K]);
    }
} Main public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int A = Integer.parseInt(sc.next());
	int B = Integer.parseInt(sc.next());
	int K = Integer.parseInt(sc.next());
	int[] arr = new int[100];
	int cnt = 0;
	for(int i = 1; i<=Math.min(A,B); i++) {
	    if(A%i==0 && B%i == 0) {
		arr[cnt] = i;
		cnt++;
	    }
	}
	Arrays.sort(arr);
	System.out.println(arr[arr.length-K]);
    } main {
	Scanner sc = new Scanner(System.in);
	int A = Integer.parseInt(sc.next());
	int B = Integer.parseInt(sc.next());
	int K = Integer.parseInt(sc.next());
	int[] arr = new int[100];
	int cnt = 0;
	for(int i = 1; i<=Math.min(A,B); i++) {
	    if(A%i==0 && B%i == 0) {
		arr[cnt] = i;
		cnt++;
	    }
	}
	Arrays.sort(arr);
	System.out.println(arr[arr.length-K]);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int A = Integer.parseInt(sc.next()); A Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int B = Integer.parseInt(sc.next()); B Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int K = Integer.parseInt(sc.next()); K Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int[] arr = new int[100]; arr new int[100] 100 int cnt = 0; cnt 0 for(int i = 1; i<=Math.min(A,B); i++) {
	    if(A%i==0 && B%i == 0) {
		arr[cnt] = i;
		cnt++;
	    }
	} int i = 1; int i = 1; i 1 i<=Math.min(A,B) i Math.min(A,B) Math.min Math A B i++ i++ i {
	    if(A%i==0 && B%i == 0) {
		arr[cnt] = i;
		cnt++;
	    }
	} {
	    if(A%i==0 && B%i == 0) {
		arr[cnt] = i;
		cnt++;
	    }
	} if(A%i==0 && B%i == 0) {
		arr[cnt] = i;
		cnt++;
	    } A%i==0 && B%i == 0 A%i==0 A%i A i 0 B%i == 0 B%i B i 0 {
		arr[cnt] = i;
		cnt++;
	    } arr[cnt] = i arr[cnt] arr cnt i cnt++ cnt Arrays.sort(arr) Arrays.sort Arrays arr System.out.println(arr[arr.length-K]) System.out.println System.out System System.out arr[arr.length-K] arr arr.length-K arr.length arr arr.length K String[] args args
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int A = Integer.parseInt(sc.next());
	int B = Integer.parseInt(sc.next());
	int K = Integer.parseInt(sc.next());
	int[] arr = new int[100];
	int cnt = 0;
	for(int i = 1; i<=Math.min(A,B); i++) {
	    if(A%i==0 && B%i == 0) {
		arr[cnt] = i;
		cnt++;
	    }
	}
	Arrays.sort(arr);
	System.out.println(arr[arr.length-K]);
    }
}