import java.util.Arrays;
import java.util.Scanner;


class Main {
    public static void main(String[] args) {
    	
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int Q = sc.nextInt();
        
        int[] ans = new int[101];
        
        for(int i = 100;i > 0 ; i--) {
        	if((A%i==0) && (B%i==0)) {
        		ans[i] = i;
        	}
        }
        Arrays.sort(ans);
        System.out.println(ans[101-Q]);
    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util class Main {
    public static void main(String[] args) {
    	
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int Q = sc.nextInt();
        
        int[] ans = new int[101];
        
        for(int i = 100;i > 0 ; i--) {
        	if((A%i==0) && (B%i==0)) {
        		ans[i] = i;
        	}
        }
        Arrays.sort(ans);
        System.out.println(ans[101-Q]);
    }
} Main public static void main(String[] args) {
    	
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int Q = sc.nextInt();
        
        int[] ans = new int[101];
        
        for(int i = 100;i > 0 ; i--) {
        	if((A%i==0) && (B%i==0)) {
        		ans[i] = i;
        	}
        }
        Arrays.sort(ans);
        System.out.println(ans[101-Q]);
    } main {
    	
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int Q = sc.nextInt();
        
        int[] ans = new int[101];
        
        for(int i = 100;i > 0 ; i--) {
        	if((A%i==0) && (B%i==0)) {
        		ans[i] = i;
        	}
        }
        Arrays.sort(ans);
        System.out.println(ans[101-Q]);
    } 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 Q = sc.nextInt(); Q sc.nextInt() sc.nextInt sc int[] ans = new int[101]; ans new int[101] 101 for(int i = 100;i > 0 ; i--) {
        	if((A%i==0) && (B%i==0)) {
        		ans[i] = i;
        	}
        } int i = 100; int i = 100; i 100 i > 0 i 0 i-- i-- i {
        	if((A%i==0) && (B%i==0)) {
        		ans[i] = i;
        	}
        } {
        	if((A%i==0) && (B%i==0)) {
        		ans[i] = i;
        	}
        } if((A%i==0) && (B%i==0)) {
        		ans[i] = i;
        	} (A%i==0) && (B%i==0) (A%i==0) A%i A i 0 (B%i==0) B%i B i 0 {
        		ans[i] = i;
        	} ans[i] = i ans[i] ans i i Arrays.sort(ans) Arrays.sort Arrays ans System.out.println(ans[101-Q]) System.out.println System.out System System.out ans[101-Q] ans 101-Q 101 Q String[] args args
import java.util.Arrays;
import java.util.Scanner;


class Main {
    public static void main(String[] args) {
    	
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int Q = sc.nextInt();
        
        int[] ans = new int[101];
        
        for(int i = 100;i > 0 ; i--) {
        	if((A%i==0) && (B%i==0)) {
        		ans[i] = i;
        	}
        }
        Arrays.sort(ans);
        System.out.println(ans[101-Q]);
    }
}