
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int K = scan.nextInt();
		int min = 0;
		int count = 0;

		if (A < B) {
			min = A;
		} else {
			min = B;
		}

		for (int i = min; i >= 1; i--) {
			if(A%i==0 && B%i==0) {
				count++;
				if(count==K) {
					System.out.println(i);
					break;
				}
			}
		}
		scan.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int K = scan.nextInt();
		int min = 0;
		int count = 0;

		if (A < B) {
			min = A;
		} else {
			min = B;
		}

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

		if (A < B) {
			min = A;
		} else {
			min = B;
		}

		for (int i = min; i >= 1; i--) {
			if(A%i==0 && B%i==0) {
				count++;
				if(count==K) {
					System.out.println(i);
					break;
				}
			}
		}
		scan.close();
	} main {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int K = scan.nextInt();
		int min = 0;
		int count = 0;

		if (A < B) {
			min = A;
		} else {
			min = B;
		}

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

		if (A < B) {
			min = A;
		} else {
			min = B;
		}

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

		if (A < B) {
			min = A;
		} else {
			min = B;
		}

		for (int i = min; i >= 1; i--) {
			if(A%i==0 && B%i==0) {
				count++;
				if(count==K) {
					System.out.println(i);
					break;
				}
			}
		}
		scan.close();
	}
} Main

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int K = scan.nextInt();
		int min = 0;
		int count = 0;

		if (A < B) {
			min = A;
		} else {
			min = B;
		}

		for (int i = min; i >= 1; i--) {
			if(A%i==0 && B%i==0) {
				count++;
				if(count==K) {
					System.out.println(i);
					break;
				}
			}
		}
		scan.close();
	}
}
