import 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 C = A;

    if (A < B) {
      C = B;
    }

    Deque<Integer> deque = new ArrayDeque<>();

    for (int i = 1; i <= C; i++) {
      if ((A % i == 0) && (B % i == 0)) {
        deque.push(i);
      }
    }

    int s = 0;

    for (int i = 0; i < K; i++) {
      s = deque.pollFirst();
    }

    System.out.println(s);

  }

} import java.util.*; util.* java 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 C = A;

    if (A < B) {
      C = B;
    }

    Deque<Integer> deque = new ArrayDeque<>();

    for (int i = 1; i <= C; i++) {
      if ((A % i == 0) && (B % i == 0)) {
        deque.push(i);
      }
    }

    int s = 0;

    for (int i = 0; i < K; i++) {
      s = deque.pollFirst();
    }

    System.out.println(s);

  }

} 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 C = A;

    if (A < B) {
      C = B;
    }

    Deque<Integer> deque = new ArrayDeque<>();

    for (int i = 1; i <= C; i++) {
      if ((A % i == 0) && (B % i == 0)) {
        deque.push(i);
      }
    }

    int s = 0;

    for (int i = 0; i < K; i++) {
      s = deque.pollFirst();
    }

    System.out.println(s);

  } main {

    Scanner sc = new Scanner(System.in);

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

    sc.close();

    int C = A;

    if (A < B) {
      C = B;
    }

    Deque<Integer> deque = new ArrayDeque<>();

    for (int i = 1; i <= C; i++) {
      if ((A % i == 0) && (B % i == 0)) {
        deque.push(i);
      }
    }

    int s = 0;

    for (int i = 0; i < K; i++) {
      s = deque.pollFirst();
    }

    System.out.println(s);

  } 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 C = A; C A if (A < B) {
      C = B;
    } A < B A B {
      C = B;
    } C = B C B Deque<Integer> deque = new ArrayDeque<>(); deque new ArrayDeque<>() for (int i = 1; i <= C; i++) {
      if ((A % i == 0) && (B % i == 0)) {
        deque.push(i);
      }
    } int i = 1; int i = 1; i 1 i <= C i C i++ i++ i {
      if ((A % i == 0) && (B % i == 0)) {
        deque.push(i);
      }
    } {
      if ((A % i == 0) && (B % i == 0)) {
        deque.push(i);
      }
    } if ((A % i == 0) && (B % i == 0)) {
        deque.push(i);
      } (A % i == 0) && (B % i == 0) (A % i == 0) A % i A i 0 (B % i == 0) B % i B i 0 {
        deque.push(i);
      } deque.push(i) deque.push deque i int s = 0; s 0 for (int i = 0; i < K; i++) {
      s = deque.pollFirst();
    } int i = 0; int i = 0; i 0 i < K i K i++ i++ i {
      s = deque.pollFirst();
    } {
      s = deque.pollFirst();
    } s = deque.pollFirst() s deque.pollFirst() deque.pollFirst deque System.out.println(s) System.out.println System.out System System.out s 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 C = A;

    if (A < B) {
      C = B;
    }

    Deque<Integer> deque = new ArrayDeque<>();

    for (int i = 1; i <= C; i++) {
      if ((A % i == 0) && (B % i == 0)) {
        deque.push(i);
      }
    }

    int s = 0;

    for (int i = 0; i < K; i++) {
      s = deque.pollFirst();
    }

    System.out.println(s);

  }

} 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 C = A;

    if (A < B) {
      C = B;
    }

    Deque<Integer> deque = new ArrayDeque<>();

    for (int i = 1; i <= C; i++) {
      if ((A % i == 0) && (B % i == 0)) {
        deque.push(i);
      }
    }

    int s = 0;

    for (int i = 0; i < K; i++) {
      s = deque.pollFirst();
    }

    System.out.println(s);

  }

} Main
import 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 C = A;

    if (A < B) {
      C = B;
    }

    Deque<Integer> deque = new ArrayDeque<>();

    for (int i = 1; i <= C; i++) {
      if ((A % i == 0) && (B % i == 0)) {
        deque.push(i);
      }
    }

    int s = 0;

    for (int i = 0; i < K; i++) {
      s = deque.pollFirst();
    }

    System.out.println(s);

  }

}