import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
    	Scanner input = new Scanner(System.in);
      	int A = input.nextInt();
        int B = input.nextInt();
      	int K = input.nextInt();
      
      	if (A > B) {
        	int tmp = A;
          	A = B;
          	B = tmp;
        }
      	int[] ab = new int[A];
      	int index = 0;
      
      	for (int i = 1; i <= A; i++) {
        	if (A % i == 0 && B % i == 0) {
              	ab[index] = i;
              	index++;
            }
        }
      
      System.out.print(ab[index - K]);

    }
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
    	Scanner input = new Scanner(System.in);
      	int A = input.nextInt();
        int B = input.nextInt();
      	int K = input.nextInt();
      
      	if (A > B) {
        	int tmp = A;
          	A = B;
          	B = tmp;
        }
      	int[] ab = new int[A];
      	int index = 0;
      
      	for (int i = 1; i <= A; i++) {
        	if (A % i == 0 && B % i == 0) {
              	ab[index] = i;
              	index++;
            }
        }
      
      System.out.print(ab[index - K]);

    }
} Main public static void main(String[] args) {
    	Scanner input = new Scanner(System.in);
      	int A = input.nextInt();
        int B = input.nextInt();
      	int K = input.nextInt();
      
      	if (A > B) {
        	int tmp = A;
          	A = B;
          	B = tmp;
        }
      	int[] ab = new int[A];
      	int index = 0;
      
      	for (int i = 1; i <= A; i++) {
        	if (A % i == 0 && B % i == 0) {
              	ab[index] = i;
              	index++;
            }
        }
      
      System.out.print(ab[index - K]);

    } main {
    	Scanner input = new Scanner(System.in);
      	int A = input.nextInt();
        int B = input.nextInt();
      	int K = input.nextInt();
      
      	if (A > B) {
        	int tmp = A;
          	A = B;
          	B = tmp;
        }
      	int[] ab = new int[A];
      	int index = 0;
      
      	for (int i = 1; i <= A; i++) {
        	if (A % i == 0 && B % i == 0) {
              	ab[index] = i;
              	index++;
            }
        }
      
      System.out.print(ab[index - K]);

    } Scanner input = new Scanner(System.in); input new Scanner(System.in) int A = input.nextInt(); A input.nextInt() input.nextInt input int B = input.nextInt(); B input.nextInt() input.nextInt input int K = input.nextInt(); K input.nextInt() input.nextInt input if (A > B) {
        	int tmp = A;
          	A = B;
          	B = tmp;
        } A > B A B {
        	int tmp = A;
          	A = B;
          	B = tmp;
        } int tmp = A; tmp A A = B A B B = tmp B tmp int[] ab = new int[A]; ab new int[A] A int index = 0; index 0 for (int i = 1; i <= A; i++) {
        	if (A % i == 0 && B % i == 0) {
              	ab[index] = i;
              	index++;
            }
        } int i = 1; int i = 1; i 1 i <= A i A i++ i++ i {
        	if (A % i == 0 && B % i == 0) {
              	ab[index] = i;
              	index++;
            }
        } {
        	if (A % i == 0 && B % i == 0) {
              	ab[index] = i;
              	index++;
            }
        } if (A % i == 0 && B % i == 0) {
              	ab[index] = i;
              	index++;
            } A % i == 0 && B % i == 0 A % i == 0 A % i A i 0 B % i == 0 B % i B i 0 {
              	ab[index] = i;
              	index++;
            } ab[index] = i ab[index] ab index i index++ index System.out.print(ab[index - K]) System.out.print System.out System System.out ab[index - K] ab index - K index K String[] args args public class Main {
	public static void main(String[] args) {
    	Scanner input = new Scanner(System.in);
      	int A = input.nextInt();
        int B = input.nextInt();
      	int K = input.nextInt();
      
      	if (A > B) {
        	int tmp = A;
          	A = B;
          	B = tmp;
        }
      	int[] ab = new int[A];
      	int index = 0;
      
      	for (int i = 1; i <= A; i++) {
        	if (A % i == 0 && B % i == 0) {
              	ab[index] = i;
              	index++;
            }
        }
      
      System.out.print(ab[index - K]);

    }
} public class Main {
	public static void main(String[] args) {
    	Scanner input = new Scanner(System.in);
      	int A = input.nextInt();
        int B = input.nextInt();
      	int K = input.nextInt();
      
      	if (A > B) {
        	int tmp = A;
          	A = B;
          	B = tmp;
        }
      	int[] ab = new int[A];
      	int index = 0;
      
      	for (int i = 1; i <= A; i++) {
        	if (A % i == 0 && B % i == 0) {
              	ab[index] = i;
              	index++;
            }
        }
      
      System.out.print(ab[index - K]);

    }
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
    	Scanner input = new Scanner(System.in);
      	int A = input.nextInt();
        int B = input.nextInt();
      	int K = input.nextInt();
      
      	if (A > B) {
        	int tmp = A;
          	A = B;
          	B = tmp;
        }
      	int[] ab = new int[A];
      	int index = 0;
      
      	for (int i = 1; i <= A; i++) {
        	if (A % i == 0 && B % i == 0) {
              	ab[index] = i;
              	index++;
            }
        }
      
      System.out.print(ab[index - K]);

    }
}
