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();

		System.out.println(Divisor(A,B,K));

		sc.close();

	}

	public static int Divisor(int a,int b,int k) {

		int ans=0;

		for(int i=100;i>0;i--) {
			if(a%i==0 && b%i==0) {

				//System.out.println(i+" "+k);

				k--;
				ans=i;
				if(k==0) break;
			}
		}

		return 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();

		System.out.println(Divisor(A,B,K));

		sc.close();

	}

	public static int Divisor(int a,int b,int k) {

		int ans=0;

		for(int i=100;i>0;i--) {
			if(a%i==0 && b%i==0) {

				//System.out.println(i+" "+k);

				k--;
				ans=i;
				if(k==0) break;
			}
		}

		return 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();

		System.out.println(Divisor(A,B,K));

		sc.close();

	} main {

		Scanner sc=new Scanner(System.in);

		int A=sc.nextInt();
		int B=sc.nextInt();
		int K=sc.nextInt();

		System.out.println(Divisor(A,B,K));

		sc.close();

	} 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 System.out.println(Divisor(A,B,K)) System.out.println System.out System System.out Divisor(A,B,K) Divisor A B K sc.close() sc.close sc String[] args args public static int Divisor(int a,int b,int k) {

		int ans=0;

		for(int i=100;i>0;i--) {
			if(a%i==0 && b%i==0) {

				//System.out.println(i+" "+k);

				k--;
				ans=i;
				if(k==0) break;
			}
		}

		return ans;

	} Divisor {

		int ans=0;

		for(int i=100;i>0;i--) {
			if(a%i==0 && b%i==0) {

				//System.out.println(i+" "+k);

				k--;
				ans=i;
				if(k==0) break;
			}
		}

		return ans;

	} int ans=0; ans 0 for(int i=100;i>0;i--) {
			if(a%i==0 && b%i==0) {

				//System.out.println(i+" "+k);

				k--;
				ans=i;
				if(k==0) break;
			}
		} int i=100; int i=100; i 100 i>0 i 0 i-- i-- i {
			if(a%i==0 && b%i==0) {

				//System.out.println(i+" "+k);

				k--;
				ans=i;
				if(k==0) break;
			}
		} {
			if(a%i==0 && b%i==0) {

				//System.out.println(i+" "+k);

				k--;
				ans=i;
				if(k==0) break;
			}
		} if(a%i==0 && b%i==0) {

				//System.out.println(i+" "+k);

				k--;
				ans=i;
				if(k==0) break;
			} a%i==0 && b%i==0 a%i==0 a%i a i 0 b%i==0 b%i b i 0 {

				//System.out.println(i+" "+k);

				k--;
				ans=i;
				if(k==0) break;
			} k-- k ans=i ans i if(k==0) break; k==0 k 0 break; return ans; ans int a a int b b int k k 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();

		System.out.println(Divisor(A,B,K));

		sc.close();

	}

	public static int Divisor(int a,int b,int k) {

		int ans=0;

		for(int i=100;i>0;i--) {
			if(a%i==0 && b%i==0) {

				//System.out.println(i+" "+k);

				k--;
				ans=i;
				if(k==0) break;
			}
		}

		return 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();

		System.out.println(Divisor(A,B,K));

		sc.close();

	}

	public static int Divisor(int a,int b,int k) {

		int ans=0;

		for(int i=100;i>0;i--) {
			if(a%i==0 && b%i==0) {

				//System.out.println(i+" "+k);

				k--;
				ans=i;
				if(k==0) break;
			}
		}

		return 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();

		System.out.println(Divisor(A,B,K));

		sc.close();

	}

	public static int Divisor(int a,int b,int k) {

		int ans=0;

		for(int i=100;i>0;i--) {
			if(a%i==0 && b%i==0) {

				//System.out.println(i+" "+k);

				k--;
				ans=i;
				if(k==0) break;
			}
		}

		return ans;

	}

}
