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();
		scan.close();
		int num=0,cnt=0;
		int max = Math.min(a, b);
		for(int i=max; i>=1;i--) {
			if(a%i==0 && b%i==0) {
				cnt++;
				if(cnt==k) {
					num=i;
					break;
				}
			}
		}
		System.out.println(num);
	}
} 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();
		scan.close();
		int num=0,cnt=0;
		int max = Math.min(a, b);
		for(int i=max; i>=1;i--) {
			if(a%i==0 && b%i==0) {
				cnt++;
				if(cnt==k) {
					num=i;
					break;
				}
			}
		}
		System.out.println(num);
	}
} 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();
		scan.close();
		int num=0,cnt=0;
		int max = Math.min(a, b);
		for(int i=max; i>=1;i--) {
			if(a%i==0 && b%i==0) {
				cnt++;
				if(cnt==k) {
					num=i;
					break;
				}
			}
		}
		System.out.println(num);
	} main {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int k = scan.nextInt();
		scan.close();
		int num=0,cnt=0;
		int max = Math.min(a, b);
		for(int i=max; i>=1;i--) {
			if(a%i==0 && b%i==0) {
				cnt++;
				if(cnt==k) {
					num=i;
					break;
				}
			}
		}
		System.out.println(num);
	} 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 scan.close() scan.close scan int num=0 num 0 cnt=0; cnt 0 int max = Math.min(a, b); max Math.min(a, b) Math.min Math a b for(int i=max; i>=1;i--) {
			if(a%i==0 && b%i==0) {
				cnt++;
				if(cnt==k) {
					num=i;
					break;
				}
			}
		} int i=max; int i=max; i max i>=1 i 1 i-- i-- i {
			if(a%i==0 && b%i==0) {
				cnt++;
				if(cnt==k) {
					num=i;
					break;
				}
			}
		} {
			if(a%i==0 && b%i==0) {
				cnt++;
				if(cnt==k) {
					num=i;
					break;
				}
			}
		} if(a%i==0 && b%i==0) {
				cnt++;
				if(cnt==k) {
					num=i;
					break;
				}
			} a%i==0 && b%i==0 a%i==0 a%i a i 0 b%i==0 b%i b i 0 {
				cnt++;
				if(cnt==k) {
					num=i;
					break;
				}
			} cnt++ cnt if(cnt==k) {
					num=i;
					break;
				} cnt==k cnt k {
					num=i;
					break;
				} num=i num i break; 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 scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int k = scan.nextInt();
		scan.close();
		int num=0,cnt=0;
		int max = Math.min(a, b);
		for(int i=max; i>=1;i--) {
			if(a%i==0 && b%i==0) {
				cnt++;
				if(cnt==k) {
					num=i;
					break;
				}
			}
		}
		System.out.println(num);
	}
} 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();
		scan.close();
		int num=0,cnt=0;
		int max = Math.min(a, b);
		for(int i=max; i>=1;i--) {
			if(a%i==0 && b%i==0) {
				cnt++;
				if(cnt==k) {
					num=i;
					break;
				}
			}
		}
		System.out.println(num);
	}
} 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();
		scan.close();
		int num=0,cnt=0;
		int max = Math.min(a, b);
		for(int i=max; i>=1;i--) {
			if(a%i==0 && b%i==0) {
				cnt++;
				if(cnt==k) {
					num=i;
					break;
				}
			}
		}
		System.out.println(num);
	}
}