import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt(),B=sc.nextInt(),K=sc.nextInt();
		int min = Math.min(A, B);
		int count=0;
		for(; min>0; min--) {
			if(A%min==0 && B%min==0) {
				count++;
				if(count==K)break;
			}
		}
		System.out.println(min);
	}
} 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(),B=sc.nextInt(),K=sc.nextInt();
		int min = Math.min(A, B);
		int count=0;
		for(; min>0; min--) {
			if(A%min==0 && B%min==0) {
				count++;
				if(count==K)break;
			}
		}
		System.out.println(min);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt(),B=sc.nextInt(),K=sc.nextInt();
		int min = Math.min(A, B);
		int count=0;
		for(; min>0; min--) {
			if(A%min==0 && B%min==0) {
				count++;
				if(count==K)break;
			}
		}
		System.out.println(min);
	} main {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt(),B=sc.nextInt(),K=sc.nextInt();
		int min = Math.min(A, B);
		int count=0;
		for(; min>0; min--) {
			if(A%min==0 && B%min==0) {
				count++;
				if(count==K)break;
			}
		}
		System.out.println(min);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int A = sc.nextInt() A sc.nextInt() sc.nextInt sc B=sc.nextInt() B sc.nextInt() sc.nextInt sc K=sc.nextInt(); K sc.nextInt() sc.nextInt sc int min = Math.min(A, B); min Math.min(A, B) Math.min Math A B int count=0; count 0 for(; min>0; min--) {
			if(A%min==0 && B%min==0) {
				count++;
				if(count==K)break;
			}
		} ; min>0 min 0 min-- min-- min {
			if(A%min==0 && B%min==0) {
				count++;
				if(count==K)break;
			}
		} {
			if(A%min==0 && B%min==0) {
				count++;
				if(count==K)break;
			}
		} if(A%min==0 && B%min==0) {
				count++;
				if(count==K)break;
			} A%min==0 && B%min==0 A%min==0 A%min A min 0 B%min==0 B%min B min 0 {
				count++;
				if(count==K)break;
			} count++ count if(count==K)break; count==K count K break; System.out.println(min) System.out.println System.out System System.out min String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt(),B=sc.nextInt(),K=sc.nextInt();
		int min = Math.min(A, B);
		int count=0;
		for(; min>0; min--) {
			if(A%min==0 && B%min==0) {
				count++;
				if(count==K)break;
			}
		}
		System.out.println(min);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt(),B=sc.nextInt(),K=sc.nextInt();
		int min = Math.min(A, B);
		int count=0;
		for(; min>0; min--) {
			if(A%min==0 && B%min==0) {
				count++;
				if(count==K)break;
			}
		}
		System.out.println(min);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt(),B=sc.nextInt(),K=sc.nextInt();
		int min = Math.min(A, B);
		int count=0;
		for(; min>0; min--) {
			if(A%min==0 && B%min==0) {
				count++;
				if(count==K)break;
			}
		}
		System.out.println(min);
	}
}
