import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int A = in.nextInt();
    int B = in.nextInt();
    int K = in.nextInt();

    List<Integer> list = new ArrayList<Integer>();

    for (int i = 1; i <= Math.min(A, B); i++) {
      if (A % i == 0 && B % i == 0) {
        list.add(i);
      }
    }

    System.out.println(list.get(list.size() - K));
  }
} import java.util.*; util.* java public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int A = in.nextInt();
    int B = in.nextInt();
    int K = in.nextInt();

    List<Integer> list = new ArrayList<Integer>();

    for (int i = 1; i <= Math.min(A, B); i++) {
      if (A % i == 0 && B % i == 0) {
        list.add(i);
      }
    }

    System.out.println(list.get(list.size() - K));
  }
} Main public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int A = in.nextInt();
    int B = in.nextInt();
    int K = in.nextInt();

    List<Integer> list = new ArrayList<Integer>();

    for (int i = 1; i <= Math.min(A, B); i++) {
      if (A % i == 0 && B % i == 0) {
        list.add(i);
      }
    }

    System.out.println(list.get(list.size() - K));
  } main {
    Scanner in = new Scanner(System.in);
    int A = in.nextInt();
    int B = in.nextInt();
    int K = in.nextInt();

    List<Integer> list = new ArrayList<Integer>();

    for (int i = 1; i <= Math.min(A, B); i++) {
      if (A % i == 0 && B % i == 0) {
        list.add(i);
      }
    }

    System.out.println(list.get(list.size() - K));
  } Scanner in = new Scanner(System.in); in new Scanner(System.in) int A = in.nextInt(); A in.nextInt() in.nextInt in int B = in.nextInt(); B in.nextInt() in.nextInt in int K = in.nextInt(); K in.nextInt() in.nextInt in List<Integer> list = new ArrayList<Integer>(); list new ArrayList<Integer>() for (int i = 1; i <= Math.min(A, B); i++) {
      if (A % i == 0 && B % i == 0) {
        list.add(i);
      }
    } int i = 1; int i = 1; i 1 i <= Math.min(A, B) i Math.min(A, B) Math.min Math A B i++ i++ i {
      if (A % i == 0 && B % i == 0) {
        list.add(i);
      }
    } {
      if (A % i == 0 && B % i == 0) {
        list.add(i);
      }
    } if (A % i == 0 && B % i == 0) {
        list.add(i);
      } A % i == 0 && B % i == 0 A % i == 0 A % i A i 0 B % i == 0 B % i B i 0 {
        list.add(i);
      } list.add(i) list.add list i System.out.println(list.get(list.size() - K)) System.out.println System.out System System.out list.get(list.size() - K) list.get list list.size() - K list.size() list.size list K String[] args args public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int A = in.nextInt();
    int B = in.nextInt();
    int K = in.nextInt();

    List<Integer> list = new ArrayList<Integer>();

    for (int i = 1; i <= Math.min(A, B); i++) {
      if (A % i == 0 && B % i == 0) {
        list.add(i);
      }
    }

    System.out.println(list.get(list.size() - K));
  }
} public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int A = in.nextInt();
    int B = in.nextInt();
    int K = in.nextInt();

    List<Integer> list = new ArrayList<Integer>();

    for (int i = 1; i <= Math.min(A, B); i++) {
      if (A % i == 0 && B % i == 0) {
        list.add(i);
      }
    }

    System.out.println(list.get(list.size() - K));
  }
} Main
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int A = in.nextInt();
    int B = in.nextInt();
    int K = in.nextInt();

    List<Integer> list = new ArrayList<Integer>();

    for (int i = 1; i <= Math.min(A, B); i++) {
      if (A % i == 0 && B % i == 0) {
        list.add(i);
      }
    }

    System.out.println(list.get(list.size() - K));
  }
}