import java.util.ArrayList;
import java.util.Collections;
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();
    ArrayList<Integer>ans  = new ArrayList<>();

    int cou = 0;
    for(int i=1; i<=100; i++) {
    	if(A%i==0 && B%i==0) {
    		ans.add(i);
    		cou++;
    	}
    	}
 Collections.sort(ans);
 
    System.out.println(ans.get(cou-K));
    }
} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util 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();
    ArrayList<Integer>ans  = new ArrayList<>();

    int cou = 0;
    for(int i=1; i<=100; i++) {
    	if(A%i==0 && B%i==0) {
    		ans.add(i);
    		cou++;
    	}
    	}
 Collections.sort(ans);
 
    System.out.println(ans.get(cou-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();
    ArrayList<Integer>ans  = new ArrayList<>();

    int cou = 0;
    for(int i=1; i<=100; i++) {
    	if(A%i==0 && B%i==0) {
    		ans.add(i);
    		cou++;
    	}
    	}
 Collections.sort(ans);
 
    System.out.println(ans.get(cou-K));
    } main {
    
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int K = sc.nextInt();
    ArrayList<Integer>ans  = new ArrayList<>();

    int cou = 0;
    for(int i=1; i<=100; i++) {
    	if(A%i==0 && B%i==0) {
    		ans.add(i);
    		cou++;
    	}
    	}
 Collections.sort(ans);
 
    System.out.println(ans.get(cou-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 ArrayList<Integer>ans  = new ArrayList<>(); ans new ArrayList<>() int cou = 0; cou 0 for(int i=1; i<=100; i++) {
    	if(A%i==0 && B%i==0) {
    		ans.add(i);
    		cou++;
    	}
    	} int i=1; int i=1; i 1 i<=100 i 100 i++ i++ i {
    	if(A%i==0 && B%i==0) {
    		ans.add(i);
    		cou++;
    	}
    	} {
    	if(A%i==0 && B%i==0) {
    		ans.add(i);
    		cou++;
    	}
    	} if(A%i==0 && B%i==0) {
    		ans.add(i);
    		cou++;
    	} A%i==0 && B%i==0 A%i==0 A%i A i 0 B%i==0 B%i B i 0 {
    		ans.add(i);
    		cou++;
    	} ans.add(i) ans.add ans i cou++ cou Collections.sort(ans) Collections.sort Collections ans System.out.println(ans.get(cou-K)) System.out.println System.out System System.out ans.get(cou-K) ans.get ans cou-K cou 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();
    ArrayList<Integer>ans  = new ArrayList<>();

    int cou = 0;
    for(int i=1; i<=100; i++) {
    	if(A%i==0 && B%i==0) {
    		ans.add(i);
    		cou++;
    	}
    	}
 Collections.sort(ans);
 
    System.out.println(ans.get(cou-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();
    ArrayList<Integer>ans  = new ArrayList<>();

    int cou = 0;
    for(int i=1; i<=100; i++) {
    	if(A%i==0 && B%i==0) {
    		ans.add(i);
    		cou++;
    	}
    	}
 Collections.sort(ans);
 
    System.out.println(ans.get(cou-K));
    }
} Main
import java.util.ArrayList;
import java.util.Collections;
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();
    ArrayList<Integer>ans  = new ArrayList<>();

    int cou = 0;
    for(int i=1; i<=100; i++) {
    	if(A%i==0 && B%i==0) {
    		ans.add(i);
    		cou++;
    	}
    	}
 Collections.sort(ans);
 
    System.out.println(ans.get(cou-K));
    }
}