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();
		
		int c = gcd(A,B);
		int temp = c;
		while (K!=0){
			if (c%temp==0)
				K--;
			temp--;
			
		}
		System.out.println(temp+1);
		sc.close();

	}
	static int gcd(int m,int n) {
		if (m<n) {
			return gcd(n,m);
		}
		if (n==0) {
			return m;
		}
		return gcd(n,m%n);
	}
} 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();
		
		int c = gcd(A,B);
		int temp = c;
		while (K!=0){
			if (c%temp==0)
				K--;
			temp--;
			
		}
		System.out.println(temp+1);
		sc.close();

	}
	static int gcd(int m,int n) {
		if (m<n) {
			return gcd(n,m);
		}
		if (n==0) {
			return m;
		}
		return gcd(n,m%n);
	}
} 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();
		
		int c = gcd(A,B);
		int temp = c;
		while (K!=0){
			if (c%temp==0)
				K--;
			temp--;
			
		}
		System.out.println(temp+1);
		sc.close();

	} main {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();
		
		int c = gcd(A,B);
		int temp = c;
		while (K!=0){
			if (c%temp==0)
				K--;
			temp--;
			
		}
		System.out.println(temp+1);
		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 int c = gcd(A,B); c gcd(A,B) gcd A B int temp = c; temp c while (K!=0){
			if (c%temp==0)
				K--;
			temp--;
			
		} K!=0 K 0 {
			if (c%temp==0)
				K--;
			temp--;
			
		} if (c%temp==0)
				K--; c%temp==0 c%temp c temp 0 K-- K temp-- temp System.out.println(temp+1) System.out.println System.out System System.out temp+1 temp 1 sc.close() sc.close sc String[] args args static int gcd(int m,int n) {
		if (m<n) {
			return gcd(n,m);
		}
		if (n==0) {
			return m;
		}
		return gcd(n,m%n);
	} gcd {
		if (m<n) {
			return gcd(n,m);
		}
		if (n==0) {
			return m;
		}
		return gcd(n,m%n);
	} if (m<n) {
			return gcd(n,m);
		} m<n m n {
			return gcd(n,m);
		} return gcd(n,m); gcd(n,m) gcd n m if (n==0) {
			return m;
		} n==0 n 0 {
			return m;
		} return m; m return gcd(n,m%n); gcd(n,m%n) gcd n m%n m n int m m int n n 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();
		
		int c = gcd(A,B);
		int temp = c;
		while (K!=0){
			if (c%temp==0)
				K--;
			temp--;
			
		}
		System.out.println(temp+1);
		sc.close();

	}
	static int gcd(int m,int n) {
		if (m<n) {
			return gcd(n,m);
		}
		if (n==0) {
			return m;
		}
		return gcd(n,m%n);
	}
} 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();
		
		int c = gcd(A,B);
		int temp = c;
		while (K!=0){
			if (c%temp==0)
				K--;
			temp--;
			
		}
		System.out.println(temp+1);
		sc.close();

	}
	static int gcd(int m,int n) {
		if (m<n) {
			return gcd(n,m);
		}
		if (n==0) {
			return m;
		}
		return gcd(n,m%n);
	}
} 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();
		
		int c = gcd(A,B);
		int temp = c;
		while (K!=0){
			if (c%temp==0)
				K--;
			temp--;
			
		}
		System.out.println(temp+1);
		sc.close();

	}
	static int gcd(int m,int n) {
		if (m<n) {
			return gcd(n,m);
		}
		if (n==0) {
			return m;
		}
		return gcd(n,m%n);
	}
}
