import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
		int b = scn.nextInt();
		int k = scn.nextInt();
		int n;
		if (a - b > 0) {
			n = b;
		} else {
			n = a;
		}
		for (int i = n; 0 < i; i--) {
			if (a % i == 0 && b % i == 0) {
				k--;
				if (k == 0) {
					System.out.println(i);
					break;
				}
			}
		}
		scn.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
		int b = scn.nextInt();
		int k = scn.nextInt();
		int n;
		if (a - b > 0) {
			n = b;
		} else {
			n = a;
		}
		for (int i = n; 0 < i; i--) {
			if (a % i == 0 && b % i == 0) {
				k--;
				if (k == 0) {
					System.out.println(i);
					break;
				}
			}
		}
		scn.close();
	}
} Main public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
		int b = scn.nextInt();
		int k = scn.nextInt();
		int n;
		if (a - b > 0) {
			n = b;
		} else {
			n = a;
		}
		for (int i = n; 0 < i; i--) {
			if (a % i == 0 && b % i == 0) {
				k--;
				if (k == 0) {
					System.out.println(i);
					break;
				}
			}
		}
		scn.close();
	} main {
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
		int b = scn.nextInt();
		int k = scn.nextInt();
		int n;
		if (a - b > 0) {
			n = b;
		} else {
			n = a;
		}
		for (int i = n; 0 < i; i--) {
			if (a % i == 0 && b % i == 0) {
				k--;
				if (k == 0) {
					System.out.println(i);
					break;
				}
			}
		}
		scn.close();
	} Scanner scn = new Scanner(System.in); scn new Scanner(System.in) int a = scn.nextInt(); a scn.nextInt() scn.nextInt scn int b = scn.nextInt(); b scn.nextInt() scn.nextInt scn int k = scn.nextInt(); k scn.nextInt() scn.nextInt scn int n; n if (a - b > 0) {
			n = b;
		} else {
			n = a;
		} a - b > 0 a - b a b 0 {
			n = b;
		} n = b n b {
			n = a;
		} n = a n a for (int i = n; 0 < i; i--) {
			if (a % i == 0 && b % i == 0) {
				k--;
				if (k == 0) {
					System.out.println(i);
					break;
				}
			}
		} int i = n; int i = n; i n 0 < i 0 i i-- i-- i {
			if (a % i == 0 && b % i == 0) {
				k--;
				if (k == 0) {
					System.out.println(i);
					break;
				}
			}
		} {
			if (a % i == 0 && b % i == 0) {
				k--;
				if (k == 0) {
					System.out.println(i);
					break;
				}
			}
		} if (a % i == 0 && b % i == 0) {
				k--;
				if (k == 0) {
					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 {
				k--;
				if (k == 0) {
					System.out.println(i);
					break;
				}
			} k-- k if (k == 0) {
					System.out.println(i);
					break;
				} k == 0 k 0 {
					System.out.println(i);
					break;
				} System.out.println(i) System.out.println System.out System System.out i break; scn.close() scn.close scn String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
		int b = scn.nextInt();
		int k = scn.nextInt();
		int n;
		if (a - b > 0) {
			n = b;
		} else {
			n = a;
		}
		for (int i = n; 0 < i; i--) {
			if (a % i == 0 && b % i == 0) {
				k--;
				if (k == 0) {
					System.out.println(i);
					break;
				}
			}
		}
		scn.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
		int b = scn.nextInt();
		int k = scn.nextInt();
		int n;
		if (a - b > 0) {
			n = b;
		} else {
			n = a;
		}
		for (int i = n; 0 < i; i--) {
			if (a % i == 0 && b % i == 0) {
				k--;
				if (k == 0) {
					System.out.println(i);
					break;
				}
			}
		}
		scn.close();
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
		int b = scn.nextInt();
		int k = scn.nextInt();
		int n;
		if (a - b > 0) {
			n = b;
		} else {
			n = a;
		}
		for (int i = n; 0 < i; i--) {
			if (a % i == 0 && b % i == 0) {
				k--;
				if (k == 0) {
					System.out.println(i);
					break;
				}
			}
		}
		scn.close();
	}
}