import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int a=s.nextInt();
		int b=s.nextInt();
		int k=s.nextInt();
		s.close();
		int num=100;
		int count=0;
		while(num>0){
			if((a%num==0)&&(b%num==0)){
				count++;
				if(count==k)break;
			}
			num--;
		}
		System.out.println(num);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int a=s.nextInt();
		int b=s.nextInt();
		int k=s.nextInt();
		s.close();
		int num=100;
		int count=0;
		while(num>0){
			if((a%num==0)&&(b%num==0)){
				count++;
				if(count==k)break;
			}
			num--;
		}
		System.out.println(num);
	}
} Main public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int a=s.nextInt();
		int b=s.nextInt();
		int k=s.nextInt();
		s.close();
		int num=100;
		int count=0;
		while(num>0){
			if((a%num==0)&&(b%num==0)){
				count++;
				if(count==k)break;
			}
			num--;
		}
		System.out.println(num);
	} main {
		Scanner s = new Scanner(System.in);
		int a=s.nextInt();
		int b=s.nextInt();
		int k=s.nextInt();
		s.close();
		int num=100;
		int count=0;
		while(num>0){
			if((a%num==0)&&(b%num==0)){
				count++;
				if(count==k)break;
			}
			num--;
		}
		System.out.println(num);
	} Scanner s = new Scanner(System.in); s new Scanner(System.in) int a=s.nextInt(); a s.nextInt() s.nextInt s int b=s.nextInt(); b s.nextInt() s.nextInt s int k=s.nextInt(); k s.nextInt() s.nextInt s s.close() s.close s int num=100; num 100 int count=0; count 0 while(num>0){
			if((a%num==0)&&(b%num==0)){
				count++;
				if(count==k)break;
			}
			num--;
		} num>0 num 0 {
			if((a%num==0)&&(b%num==0)){
				count++;
				if(count==k)break;
			}
			num--;
		} if((a%num==0)&&(b%num==0)){
				count++;
				if(count==k)break;
			} (a%num==0)&&(b%num==0) (a%num==0) a%num a num 0 (b%num==0) b%num b num 0 {
				count++;
				if(count==k)break;
			} count++ count if(count==k)break; count==k count k break; num-- num System.out.println(num) System.out.println System.out System System.out num String[] args args public class Main {
	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int a=s.nextInt();
		int b=s.nextInt();
		int k=s.nextInt();
		s.close();
		int num=100;
		int count=0;
		while(num>0){
			if((a%num==0)&&(b%num==0)){
				count++;
				if(count==k)break;
			}
			num--;
		}
		System.out.println(num);
	}
} public class Main {
	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int a=s.nextInt();
		int b=s.nextInt();
		int k=s.nextInt();
		s.close();
		int num=100;
		int count=0;
		while(num>0){
			if((a%num==0)&&(b%num==0)){
				count++;
				if(count==k)break;
			}
			num--;
		}
		System.out.println(num);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int a=s.nextInt();
		int b=s.nextInt();
		int k=s.nextInt();
		s.close();
		int num=100;
		int count=0;
		while(num>0){
			if((a%num==0)&&(b%num==0)){
				count++;
				if(count==k)break;
			}
			num--;
		}
		System.out.println(num);
	}
}