import java.util.ArrayList;
import java.util.List;
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 c = sc.nextInt();
		
		int max= Math.max(a, b);
		List<Integer> result = new ArrayList<Integer>();
		for(int i =1 ; i <=max; i++) {
			if(a%i ==0 && b%i ==0) {
				result.add(i);
			}
		}
		System.out.println(result.get(result.size()-c));
		sc.close();
	}
} import java.util.ArrayList; ArrayList java.util import java.util.List; List 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 c = sc.nextInt();
		
		int max= Math.max(a, b);
		List<Integer> result = new ArrayList<Integer>();
		for(int i =1 ; i <=max; i++) {
			if(a%i ==0 && b%i ==0) {
				result.add(i);
			}
		}
		System.out.println(result.get(result.size()-c));
		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		int max= Math.max(a, b);
		List<Integer> result = new ArrayList<Integer>();
		for(int i =1 ; i <=max; i++) {
			if(a%i ==0 && b%i ==0) {
				result.add(i);
			}
		}
		System.out.println(result.get(result.size()-c));
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		int max= Math.max(a, b);
		List<Integer> result = new ArrayList<Integer>();
		for(int i =1 ; i <=max; i++) {
			if(a%i ==0 && b%i ==0) {
				result.add(i);
			}
		}
		System.out.println(result.get(result.size()-c));
		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 c = sc.nextInt(); c sc.nextInt() sc.nextInt sc int max= Math.max(a, b); max Math.max(a, b) Math.max Math a b List<Integer> result = new ArrayList<Integer>(); result new ArrayList<Integer>() for(int i =1 ; i <=max; i++) {
			if(a%i ==0 && b%i ==0) {
				result.add(i);
			}
		} int i =1 ; int i =1 ; i 1 i <=max i max i++ i++ i {
			if(a%i ==0 && b%i ==0) {
				result.add(i);
			}
		} {
			if(a%i ==0 && b%i ==0) {
				result.add(i);
			}
		} if(a%i ==0 && b%i ==0) {
				result.add(i);
			} a%i ==0 && b%i ==0 a%i ==0 a%i a i 0 b%i ==0 b%i b i 0 {
				result.add(i);
			} result.add(i) result.add result i System.out.println(result.get(result.size()-c)) System.out.println System.out System System.out result.get(result.size()-c) result.get result result.size()-c result.size() result.size result c 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 c = sc.nextInt();
		
		int max= Math.max(a, b);
		List<Integer> result = new ArrayList<Integer>();
		for(int i =1 ; i <=max; i++) {
			if(a%i ==0 && b%i ==0) {
				result.add(i);
			}
		}
		System.out.println(result.get(result.size()-c));
		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 c = sc.nextInt();
		
		int max= Math.max(a, b);
		List<Integer> result = new ArrayList<Integer>();
		for(int i =1 ; i <=max; i++) {
			if(a%i ==0 && b%i ==0) {
				result.add(i);
			}
		}
		System.out.println(result.get(result.size()-c));
		sc.close();
	}
} Main
import java.util.ArrayList;
import java.util.List;
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 c = sc.nextInt();
		
		int max= Math.max(a, b);
		List<Integer> result = new ArrayList<Integer>();
		for(int i =1 ; i <=max; i++) {
			if(a%i ==0 && b%i ==0) {
				result.add(i);
			}
		}
		System.out.println(result.get(result.size()-c));
		sc.close();
	}
}