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();
		int ans = 0;
		int count = 0;
		for(int i = Math.min(A,B); i >= 1; i--) {
			if(A % i == 0 && B % i==0) {
				count++;	
				ans = i;
				if(count == K) {
					break;
				}
			}
		}
		System.out.print(ans);
	}
} 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();
		int ans = 0;
		int count = 0;
		for(int i = Math.min(A,B); i >= 1; i--) {
			if(A % i == 0 && B % i==0) {
				count++;	
				ans = i;
				if(count == K) {
					break;
				}
			}
		}
		System.out.print(ans);
	}
} 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();
		int ans = 0;
		int count = 0;
		for(int i = Math.min(A,B); i >= 1; i--) {
			if(A % i == 0 && B % i==0) {
				count++;	
				ans = i;
				if(count == K) {
					break;
				}
			}
		}
		System.out.print(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();
		int ans = 0;
		int count = 0;
		for(int i = Math.min(A,B); i >= 1; i--) {
			if(A % i == 0 && B % i==0) {
				count++;	
				ans = i;
				if(count == K) {
					break;
				}
			}
		}
		System.out.print(ans);
	} 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 int ans = 0; ans 0 int count = 0; count 0 for(int i = Math.min(A,B); i >= 1; i--) {
			if(A % i == 0 && B % i==0) {
				count++;	
				ans = i;
				if(count == K) {
					break;
				}
			}
		} int i = Math.min(A,B); int i = Math.min(A,B); i Math.min(A,B) Math.min Math A B i >= 1 i 1 i-- i-- i {
			if(A % i == 0 && B % i==0) {
				count++;	
				ans = i;
				if(count == K) {
					break;
				}
			}
		} {
			if(A % i == 0 && B % i==0) {
				count++;	
				ans = i;
				if(count == K) {
					break;
				}
			}
		} if(A % i == 0 && B % i==0) {
				count++;	
				ans = i;
				if(count == K) {
					break;
				}
			} A % i == 0 && B % i==0 A % i == 0 A % i A i 0 B % i==0 B % i B i 0 {
				count++;	
				ans = i;
				if(count == K) {
					break;
				}
			} count++ count ans = i ans i if(count == K) {
					break;
				} count == K count K {
					break;
				} break; System.out.print(ans) System.out.print System.out System System.out ans 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();
		int ans = 0;
		int count = 0;
		for(int i = Math.min(A,B); i >= 1; i--) {
			if(A % i == 0 && B % i==0) {
				count++;	
				ans = i;
				if(count == K) {
					break;
				}
			}
		}
		System.out.print(ans);
	}
} 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();
		int ans = 0;
		int count = 0;
		for(int i = Math.min(A,B); i >= 1; i--) {
			if(A % i == 0 && B % i==0) {
				count++;	
				ans = i;
				if(count == K) {
					break;
				}
			}
		}
		System.out.print(ans);
	}
} Main
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();
		int ans = 0;
		int count = 0;
		for(int i = Math.min(A,B); i >= 1; i--) {
			if(A % i == 0 && B % i==0) {
				count++;	
				ans = i;
				if(count == K) {
					break;
				}
			}
		}
		System.out.print(ans);
	}
}