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();
		sc.close();

		int ans = 0;
		int kailen = 0;
		int[] kai = new int[100];
		int i;
		for (i=1; i<=100; i++) {
			if (a % i == 0 && b % i == 0) {
				kai[kailen]= i;
				ans++;
				kailen++;
			}
		}
		System.out.println(kai[kailen-k]);
	}
} 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();
		sc.close();

		int ans = 0;
		int kailen = 0;
		int[] kai = new int[100];
		int i;
		for (i=1; i<=100; i++) {
			if (a % i == 0 && b % i == 0) {
				kai[kailen]= i;
				ans++;
				kailen++;
			}
		}
		System.out.println(kai[kailen-k]);
	}
} 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();
		sc.close();

		int ans = 0;
		int kailen = 0;
		int[] kai = new int[100];
		int i;
		for (i=1; i<=100; i++) {
			if (a % i == 0 && b % i == 0) {
				kai[kailen]= i;
				ans++;
				kailen++;
			}
		}
		System.out.println(kai[kailen-k]);
	} main {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		sc.close();

		int ans = 0;
		int kailen = 0;
		int[] kai = new int[100];
		int i;
		for (i=1; i<=100; i++) {
			if (a % i == 0 && b % i == 0) {
				kai[kailen]= i;
				ans++;
				kailen++;
			}
		}
		System.out.println(kai[kailen-k]);
	} 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 sc.close() sc.close sc int ans = 0; ans 0 int kailen = 0; kailen 0 int[] kai = new int[100]; kai new int[100] 100 int i; i for (i=1; i<=100; i++) {
			if (a % i == 0 && b % i == 0) {
				kai[kailen]= i;
				ans++;
				kailen++;
			}
		} i=1; i=1 i 1 i<=100 i 100 i++ i++ i {
			if (a % i == 0 && b % i == 0) {
				kai[kailen]= i;
				ans++;
				kailen++;
			}
		} {
			if (a % i == 0 && b % i == 0) {
				kai[kailen]= i;
				ans++;
				kailen++;
			}
		} if (a % i == 0 && b % i == 0) {
				kai[kailen]= i;
				ans++;
				kailen++;
			} a % i == 0 && b % i == 0 a % i == 0 a % i a i 0 b % i == 0 b % i b i 0 {
				kai[kailen]= i;
				ans++;
				kailen++;
			} kai[kailen]= i kai[kailen] kai kailen i ans++ ans kailen++ kailen System.out.println(kai[kailen-k]) System.out.println System.out System System.out kai[kailen-k] kai kailen-k kailen k 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();
		sc.close();

		int ans = 0;
		int kailen = 0;
		int[] kai = new int[100];
		int i;
		for (i=1; i<=100; i++) {
			if (a % i == 0 && b % i == 0) {
				kai[kailen]= i;
				ans++;
				kailen++;
			}
		}
		System.out.println(kai[kailen-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();
		sc.close();

		int ans = 0;
		int kailen = 0;
		int[] kai = new int[100];
		int i;
		for (i=1; i<=100; i++) {
			if (a % i == 0 && b % i == 0) {
				kai[kailen]= i;
				ans++;
				kailen++;
			}
		}
		System.out.println(kai[kailen-k]);
	}
} 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();
		sc.close();

		int ans = 0;
		int kailen = 0;
		int[] kai = new int[100];
		int i;
		for (i=1; i<=100; i++) {
			if (a % i == 0 && b % i == 0) {
				kai[kailen]= i;
				ans++;
				kailen++;
			}
		}
		System.out.println(kai[kailen-k]);
	}
}
